From 3f3ebd88579c03538225b6033dc4d2a5c57f8c96 Mon Sep 17 00:00:00 2001 From: Mahendra Paipuri Date: Wed, 10 Apr 2024 17:19:51 +0200 Subject: [PATCH] fix: Force new instance of AsyncHTTPClient * Without new instance it will mess up JupyterHub single user extension's client Signed-off-by: Mahendra Paipuri --- jupyter_power_usage/api.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/jupyter_power_usage/api.py b/jupyter_power_usage/api.py index 5b356da..0da6379 100644 --- a/jupyter_power_usage/api.py +++ b/jupyter_power_usage/api.py @@ -108,7 +108,14 @@ class ElectrictyMapsHandler(JupyterHandler): The purpose of this proxy is to provide authentication to the API requests. """ - client = AsyncHTTPClient() + # Force a new instance to not to mess up with other instances that might exist in + # JupyterHub or other Jupyter related stacks + # + # Without this we noticed that JupyterHub will fail to spawn instances when internal + # TLS is on. The reason is that this new instantiation will override the already + # existing instance in single user extension that has SSL context configured. So + # we lose SSL context and hence cert verification will fail eventually failing spawn. + client = AsyncHTTPClient(force_instance=True) def initialize(self): # Get access token(s) from config @@ -119,7 +126,7 @@ def initialize(self): @web.authenticated async def get(self, path): - """Return emission factor data from electticity maps""" + """Return emission factor data from electricity maps""" try: query = self.request.query_arguments params = {key: query[key][0].decode() for key in query}