harvimt / quamash

Implementation of the PEP 3156 event-loop (asyncio) api using the Qt Event-Loop
BSD 2-Clause "Simplified" License
265 stars 46 forks source link

_IocpProactor implementation causes race condition (on Windows) #55

Closed peterazmanov closed 9 years ago

peterazmanov commented 9 years ago

Quamash uses separate thread for event polling. Polling in separate thread can cause race condition with 'event initiation' which is handled in MainThread. E.g. method recv of asyncio.windows_events.IocpProactor starts waiting to receive data from socket (via call to WSARecv) in MainThread. Before recv calls self._register(ov, conn, finish_recv) to register event in self._cache event is received in parallel poller thread (via call to GetQueuedCompletionStatus) and causes KeyError, in this case event is lost forever and app hangs on exit. I believe this bug is the reason for hangs in PR #44 (issue #38).