Some of the tests in Sanic (test_request_timout, test_response_timeout, test_keep_alive_timeout) use a custom SanicClient with modified methods. This relies on overriding internal aiohttp Client classes.
In aiohttp 3.1.0 there were some breaking changes that caused the custom methods to be no longer compatible with latest upstream aiohttp Client class. See:903073283f
and:b42e0ced46
This commit adds aiohttp version checks to adapt to these changes.
This commit is contained in:
parent
8a07463a67
commit
94b9bc7950
|
@ -1,5 +1,5 @@
|
||||||
aiofiles
|
aiofiles
|
||||||
aiohttp==1.3.5
|
aiohttp>=2.3.0
|
||||||
chardet<=2.3.0
|
chardet<=2.3.0
|
||||||
beautifulsoup4
|
beautifulsoup4
|
||||||
coverage
|
coverage
|
||||||
|
|
|
@ -58,12 +58,30 @@ class DelayableTCPConnector(TCPConnector):
|
||||||
t = req.loop.time()
|
t = req.loop.time()
|
||||||
print("sending at {}".format(t), flush=True)
|
print("sending at {}".format(t), flush=True)
|
||||||
conn = next(iter(args)) # first arg is connection
|
conn = next(iter(args)) # first arg is connection
|
||||||
|
if aiohttp.__version__ >= "3.1.0":
|
||||||
|
try:
|
||||||
|
delayed_resp = await self.orig_send(*args, **kwargs)
|
||||||
|
except Exception as e:
|
||||||
|
return aiohttp.ClientResponse(req.method, req.url,
|
||||||
|
writer=None, continue100=None, timer=None,
|
||||||
|
request_info=None, auto_decompress=None, traces=[],
|
||||||
|
loop=req.loop, session=None)
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
delayed_resp = self.orig_send(*args, **kwargs)
|
delayed_resp = self.orig_send(*args, **kwargs)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return aiohttp.ClientResponse(req.method, req.url)
|
return aiohttp.ClientResponse(req.method, req.url)
|
||||||
return delayed_resp
|
return delayed_resp
|
||||||
|
|
||||||
|
if aiohttp.__version__ >= "3.1.0":
|
||||||
|
# aiohttp changed the request.send method to async
|
||||||
|
async def send(self, *args, **kwargs):
|
||||||
|
gen = self.delayed_send(*args, **kwargs)
|
||||||
|
task = self.req.loop.create_task(gen)
|
||||||
|
self.send_task = task
|
||||||
|
self._acting_as = task
|
||||||
|
return self
|
||||||
|
else:
|
||||||
def send(self, *args, **kwargs):
|
def send(self, *args, **kwargs):
|
||||||
gen = self.delayed_send(*args, **kwargs)
|
gen = self.delayed_send(*args, **kwargs)
|
||||||
task = self.req.loop.create_task(gen)
|
task = self.req.loop.create_task(gen)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user