Open perillaseed opened 6 years ago
On Windows, Quamash doesn't extend the default event loop (selector), instead it extends the Proactor event loop.
(this is because I find the Proactor more useful, since it supports subprocesses...)
Though this might be a problem with quamash itself since the error is bubbling through quamash/_windows.py, in order to really reproduce you'd need to see if this works with a non-quamash proactor event loop.
This seems like the same issue as #91. It appears to be related to the implementation of the _process_events method of the _ProactorEventLoop. By modifying the OSError except clause to set the exception on f instead of logging, I believe you can achieve the desired result.
def _process_events(self, events):
"""Process events from proactor."""
for f, callback, transferred, key, ov in events:
try:
self._logger.debug('Invoking event callback {}'.format(callback))
value = callback(transferred, key, ov)
- except OSError:
- self._logger.warning('Event callback failed', exc_info=sys.exc_info())
+ except OSError as e:
+ f.set_exception(e)
else:
f.set_result(value)
Setting the exception on f is what the standard library asyncio implementation of the IocpProactor does.
While using quamash and tcp client connect to a closed tcp server and hope to try to reconnect to this tcp server automatically, it will raised a ConnectionRefusedError and stop to reconnect it again, use asyncio.get_event_loop() has no such problem, it will keep reconnect until the tcp server open. This issus also ask in https://stackoverflow.com/questions/51093428/different-behaviours-when-using-qeventloop-and-asyncio-default-loop-with-python3, and the simplized test code can be found as follows:
and here is the exception raised: