[New-bugs-announce] [issue30679] __aexit__ not called when `run_until_complete` is interrupted by SIGINT

Arthur Darcet report at bugs.python.org
Thu Jun 15 11:27:28 EDT 2017


New submission from Arthur Darcet:

Here is the example code I am running:

```
import asyncio

class it:
	async def __aenter__(self):
		return self
	async def __aexit__(self, *_):
		print('EXIT')

async def main():
	async with it():
		await asyncio.sleep(100)

asyncio.get_event_loop().run_until_complete(main())
```


When this gets interrupted by a SIGINT, I would expect this code to display `EXIT` before the `KeyboardInterrupt` stacktrace. But instead the `__aexit__` function is simply not called.

----------
components: asyncio
messages: 296106
nosy: rthr, yselivanov
priority: normal
pull_requests: 2264
severity: normal
status: open
title: __aexit__ not called when `run_until_complete` is interrupted by SIGINT
versions: Python 3.5, Python 3.6, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30679>
_______________________________________


More information about the New-bugs-announce mailing list