{"id":990,"hash":"ca5721435fea4951178b3d6d96c75fd3c41a12fa6622159d4ee6952cc49cdea6","pattern":"aiohttp - exception ignored message","full_message":"I'm running the following code which makes 5 requests via aiohttp:\n\nimport aiohttp\nimport asyncio\n\ndef fetch_page(url, idx):\n    try:\n        url = 'http://google.com'\n        response = yield from aiohttp.request('GET', url)\n\n        print(response.status)\n    except Exception as e:\n        print(e)\n\ndef main():\n    try:\n        url = 'http://google.com'\n        urls = [url] * 5\n\n        coros = []\n        for idx, url in enumerate(urls):\n            coros.append(asyncio.Task(fetch_page(url, idx)))\n\n        yield from asyncio.gather(*coros)\n    except Exception as e:\n        print(e)\n\nif __name__ == '__main__':\n    try:\n        loop = asyncio.get_event_loop()\n        loop.run_until_complete(main())\n    except Exception as e:\n        print(e)\n\nOutput:\n\n200\n200\n200\n200\n200\nException ignored in: Exception ignored in: Exception ignored in: Exception ignored in: Exception ignored in:\n\nNote: There is no additional information as to what/where the exception is.\n\nWhat's causing this and are there any tips to debug it?","ecosystem":"pypi","package_name":"python-3.x","package_version":null,"solution":"I'm not exactly sure why, but it seems that leaving the aiohttp.ClientResponse object open is causing an unraisable exception to be thrown when the interpreter exits. On my system, this results in warnings like this, rather than \"Exception ignored in\" messages:\n\nsys:1: ResourceWarning: unclosed <socket object at 0x7f44fce557a8>\nsys:1: ResourceWarning: unclosed <socket object at 0x7f44fce55718>\nsys:1: ResourceWarning: unclosed <socket object at 0x7f44fcc24a78>\nsys:1: ResourceWarning: unclosed <socket object at 0x7f44fcc248c8>\nsys:1: ResourceWarning: unclosed <socket object at 0x7f44fcc24958>\nsys:1: ResourceWarning: unclosed <socket object at 0x7f44fcc249e8>\nsys:1: ResourceWarning: unclosed <socket object at 0x7f44fcc24b08>\n\nIn any case, you can fix it by explicitly closing the ClientResponse object at the end of fetch_objects, by calling response.close().","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/29502779/aiohttp-exception-ignored-message","votes":10,"created_at":"2026-04-19T04:52:07.359885+00:00","updated_at":"2026-04-19T04:52:07.359885+00:00"}