Author mikeshardmind
Recipients asvetlov, mikeshardmind, yselivanov
Date 2020-01-06.18:29:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
When using for an asynchronous application utilizing ssl, on windows using the proactor event loop the application crashes when the loop is closed, completely skipping a finally block in the process.

This appears to be due to a __del__ method on transports used.

Manual handling of the event loop close while including a brief sleep appears to work as intended.

Both versions work fine with the selector event loop on linux.

This appears to be a somewhat known issue already, as it's been reported to aiohttp, however both the traceback, and the differing behavior seem to indicate this is an issue with the proactor event loop.

(On linux this still emits a resource warning without the sleep)

While I don't mind handling the loop cleanup, it seems like this case should also emit a resource warning rather than crashing.

If it's decided in which way this should be handled, I'm willing to contribute to or help test whatever direction the resolution for this should go. 

Traceback included below, toy version of the problem attached as code.

Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000026463039820>
Traceback (most recent call last):
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python38\lib\asyncio\", line 116, in __del__
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python38\lib\asyncio\", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python38\lib\asyncio\", line 715, in call_soon
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python38\lib\asyncio\", line 508, in _check_closed       
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Date User Action Args
2020-01-06 18:29:20mikeshardmindsetrecipients: + mikeshardmind, asvetlov, yselivanov
2020-01-06 18:29:20mikeshardmindsetmessageid: <>
2020-01-06 18:29:20mikeshardmindlinkissue39232 messages
2020-01-06 18:29:20mikeshardmindcreate