python - aiohttp - exception ignored message -
python - aiohttp - exception ignored message -
i'm running next code makes 5 requests via aiohttp:
import aiohttp import asyncio def fetch_page(url, idx): try: url = 'http://google.com' response = yield aiohttp.request('get', url) print(response.status) except exception e: print(e) def main(): try: url = 'http://google.com' urls = [url] * 5 coros = [] idx, url in enumerate(urls): coros.append(asyncio.task(fetch_page(url, idx))) yield asyncio.gather(*coros) except exception e: print(e) if __name__ == '__main__': try: loop = asyncio.get_event_loop() loop.run_until_complete(main()) except exception e: print(e)
output:
200 200 200 200 200 exception ignored in: exception ignored in: exception ignored in: exception ignored in: exception ignored in:
note: there no additional info what/where exception is.
what's causing , there tips debug it?
i'm not sure why, seems leaving aiohttp.clientresponse
object open causing unraisable exception thrown when interpreter exits. on system, results in warnings this, rather "exception ignored in" messages:
sys:1: resourcewarning: unclosed <socket object @ 0x7f44fce557a8> sys:1: resourcewarning: unclosed <socket object @ 0x7f44fce55718> sys:1: resourcewarning: unclosed <socket object @ 0x7f44fcc24a78> sys:1: resourcewarning: unclosed <socket object @ 0x7f44fcc248c8> sys:1: resourcewarning: unclosed <socket object @ 0x7f44fcc24958> sys:1: resourcewarning: unclosed <socket object @ 0x7f44fcc249e8> sys:1: resourcewarning: unclosed <socket object @ 0x7f44fcc24b08>
in case, can prepare explicitly closing clientresponse
object @ end of fetch_objects
, calling response.close()
.
python python-3.x python-asyncio aiohttp
Comments
Post a Comment