tornado: construct AsyncHTTPClient each time so that it uses the right ioloop
This is a better fix for #129.
This commit is contained in:
parent
2fc1ec3355
commit
cbd7e13867
|
@ -17,7 +17,6 @@ from .httpclient import DEFAULT_USER_AGENT
|
|||
|
||||
__all__ = ['session', 'HTTPError', 'NetworkErrors']
|
||||
|
||||
client = AsyncHTTPClient()
|
||||
HTTP2_AVAILABLE = None if pycurl else False
|
||||
|
||||
def try_use_http2(curl):
|
||||
|
@ -66,7 +65,7 @@ class ResponseManager:
|
|||
self.req = req
|
||||
|
||||
async def __aenter__(self):
|
||||
return await client.fetch(self.req)
|
||||
return await AsyncHTTPClient().fetch(self.req)
|
||||
|
||||
async def __aexit__(self, exc_type, exc, tb):
|
||||
pass
|
||||
|
|
|
@ -54,12 +54,10 @@ async def get_version():
|
|||
|
||||
return __call__
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
@pytest.fixture(scope="module")
|
||||
def event_loop(request):
|
||||
"""Override pytest-asyncio's event_loop fixture,
|
||||
Don't create an instance of the default event loop for each test case.
|
||||
|
||||
The scope is session because the Tornado AsyncHTTPClient singleton remains.
|
||||
"""
|
||||
loop = asyncio.get_event_loop()
|
||||
yield loop
|
||||
|
|
Loading…
Reference in New Issue