-
-
Notifications
You must be signed in to change notification settings - Fork 161
Open
Labels
Description
I use my custom HTTP session with overridden TCPConnector.
conn = aiohttp.TCPConnector(ssl=ssl_context)
socketio.AsyncClient(
...,
http=aiohttp.ClientSession(connector=conn),
)And after the reconnect is called, the default session can override the session I passed:
python-engineio/src/engineio/async_client.py
Lines 308 to 310 in 7a41390
| if self.http is None or self.http.closed: # pragma: no cover | |
| self.http = aiohttp.ClientSession() | |
My suggestion is to create a separate method in the base class that contains the logic for creating a session.
Then you can do it like this:
# engineio.async_client.AsyncClient
class EIOCustomSession(engineio.AsyncClient):
def create_session(self):
return aiohttp.ClientSession()
async def _connect_websocket(self, url, headers, engineio_path):
...
if self.http is None or self.http.closed: # pragma: no cover
self.http = self.create_session()
...
# mymodule
class EIOCustomSession(engineio.AsyncClient):
def __init__(self, *args, **kwargs, conn=None)
self.conn = conn
def create_session(self):
return aiohttp.ClientSession(connector=self.conn)
class SIOCustomSession(socketio.AsyncClient):
def _engineio_client_class(self):
return EIOCustomSession