Author mikeshardmind
Recipients asvetlov, mikeshardmind, yselivanov
Date 2020-01-06.18:29:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1578335360.75.0.333919607495.issue39232@roundup.psfhosted.org>
In-reply-to
Content
When using asyncio.run 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\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 715, in call_soon
    self._check_closed()
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 508, in _check_closed       
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
History
Date User Action Args
2020-01-06 18:29:20mikeshardmindsetrecipients: + mikeshardmind, asvetlov, yselivanov
2020-01-06 18:29:20mikeshardmindsetmessageid: <1578335360.75.0.333919607495.issue39232@roundup.psfhosted.org>
2020-01-06 18:29:20mikeshardmindlinkissue39232 messages
2020-01-06 18:29:20mikeshardmindcreate