mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-03 16:39:25 +01:00
classes: oops, actually tell the queue thread to abort before we wait for it to stop
This commit is contained in:
parent
80cbd7a257
commit
138a52611e
19
classes.py
19
classes.py
@ -1639,6 +1639,15 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
|
||||
|
||||
self._pre_disconnect()
|
||||
|
||||
# Stop the queue thread.
|
||||
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.
|
||||
with self._queue.mutex:
|
||||
self._queue.queue[0] = None
|
||||
except IndexError:
|
||||
self._queue.put(None)
|
||||
|
||||
if self._socket is not None:
|
||||
try:
|
||||
selectdriver.unregister(self)
|
||||
@ -1650,20 +1659,12 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
|
||||
except:
|
||||
log.debug('(%s) Error on socket shutdown:', self.name, exc_info=True)
|
||||
|
||||
log.debug('(%s) disconnect: waiting for write half of socket %s to shutdown', self.name, self._socket)
|
||||
# Wait for the write half to shut down when applicable.
|
||||
if self._queue_thread is None or self._aborted_send.wait(10):
|
||||
log.debug('(%s) disconnect: closing socket %s', self.name, self._socket)
|
||||
self._socket.close()
|
||||
|
||||
# Stop the queue thread.
|
||||
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.
|
||||
with self._queue.mutex:
|
||||
self._queue.queue[0] = None
|
||||
except IndexError:
|
||||
self._queue.put(None)
|
||||
|
||||
# Stop the ping timer.
|
||||
if self._ping_timer:
|
||||
log.debug('(%s) Canceling pingTimer at %s due to disconnect() call', self.name, time.time())
|
||||
|
Loading…
Reference in New Issue
Block a user