3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-26 04:32:51 +01:00

IRCNetwork: potentially fix queue thread shutdowns (#558)

Replace unreliable appendleft() usage with replacing the first element (or adding None if the queue is empty).
This commit is contained in:
James Lu 2017-12-17 00:36:44 -08:00
parent 9a5072824d
commit 6c65d5523e

View File

@ -1450,9 +1450,13 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
self._socket.close() self._socket.close()
# Stop the queue thread. # Stop the queue thread.
if self._queue: if self._queue is not None:
try:
# XXX: queue.Queue.queue isn't actually documented, so this is probably not reliable in the long run. # XXX: queue.Queue.queue isn't actually documented, so this is probably not reliable in the long run.
self._queue.queue.appendleft(None) with self._queue.mutex:
self._queue.queue[0] = None
except IndexError:
self._queue.put(None)
# Stop the ping timer. # Stop the ping timer.
if self._ping_timer: if self._ping_timer: