Merge pull request #1180 from ashleysommer/fix_aiohttp_breakages
Fix failing tests when aiohttp>=3.1.0
This commit is contained in:
commit
ef3bdf5408
|
@ -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,18 +58,36 @@ 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
|
||||||
try:
|
if aiohttp.__version__ >= "3.1.0":
|
||||||
delayed_resp = self.orig_send(*args, **kwargs)
|
try:
|
||||||
except Exception as e:
|
delayed_resp = await self.orig_send(*args, **kwargs)
|
||||||
return aiohttp.ClientResponse(req.method, req.url)
|
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:
|
||||||
|
delayed_resp = self.orig_send(*args, **kwargs)
|
||||||
|
except Exception as e:
|
||||||
|
return aiohttp.ClientResponse(req.method, req.url)
|
||||||
return delayed_resp
|
return delayed_resp
|
||||||
|
|
||||||
def send(self, *args, **kwargs):
|
if aiohttp.__version__ >= "3.1.0":
|
||||||
gen = self.delayed_send(*args, **kwargs)
|
# aiohttp changed the request.send method to async
|
||||||
task = self.req.loop.create_task(gen)
|
async def send(self, *args, **kwargs):
|
||||||
self.send_task = task
|
gen = self.delayed_send(*args, **kwargs)
|
||||||
self._acting_as = task
|
task = self.req.loop.create_task(gen)
|
||||||
return self
|
self.send_task = task
|
||||||
|
self._acting_as = task
|
||||||
|
return self
|
||||||
|
else:
|
||||||
|
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
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
_post_connect_delay = kwargs.pop('post_connect_delay', 0)
|
_post_connect_delay = kwargs.pop('post_connect_delay', 0)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user