Skip to content

Quell async warning, and POST with body for jupyterhub 3.0 #247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ repos:
# Lint: Checks that non-binary executables have a proper shebang.
- id: check-executables-have-shebangs


# pre-commit.ci config reference: https://pre-commit.ci/#configuration
ci:
autoupdate_schedule: monthly
20 changes: 17 additions & 3 deletions batchspawner/singleuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,31 @@
from jupyterhub.utils import random_port, url_path_join
from jupyterhub.services.auth import HubAuth

import requests


def main(argv=None):
port = random_port()
hub_auth = HubAuth()
hub_auth.client_ca = os.environ.get("JUPYTERHUB_SSL_CLIENT_CA", "")
hub_auth.certfile = os.environ.get("JUPYTERHUB_SSL_CERTFILE", "")
hub_auth.keyfile = os.environ.get("JUPYTERHUB_SSL_KEYFILE", "")
hub_auth._api_request(
method="POST",
url=url_path_join(hub_auth.api_url, "batchspawner"),

url = url_path_join(hub_auth.api_url, "batchspawner")
headers = {"Authorization": f"token {hub_auth.api_token}"}

# internal_ssl kwargs
kwargs = {}
if hub_auth.certfile and hub_auth.keyfile:
kwargs["cert"] = (hub_auth.certfile, hub_auth.keyfile)
if hub_auth.client_ca:
kwargs["verify"] = hub_auth.client_ca

r = requests.post(
url,
headers={"Authorization": f"token {hub_auth.api_token}"},
json={"port": port},
**kwargs,
)

cmd_path = which(sys.argv[1])
Expand Down