Commit 4f361be7 authored by David Wilson's avatar David Wilson

issue #144: teach Select() to close its latch

Causes all threads sleeping on the select to wake.
parent 8aada264
...@@ -159,6 +159,11 @@ contexts. ...@@ -159,6 +159,11 @@ contexts.
:return: :return:
:py:class:`mitogen.core.Message` :py:class:`mitogen.core.Message`
:raises mitogen.core.TimeoutError:
Timeout was reached.
:raises mitogen.core.LatchError:
:py:meth:`close` has been called, and the underlying latch is no
longer valid.
.. py:method:: __bool__ () .. py:method:: __bool__ ()
...@@ -166,9 +171,14 @@ contexts. ...@@ -166,9 +171,14 @@ contexts.
.. py:method:: close () .. py:method:: close ()
Remove the select's notifier function from each registered receiver. Remove the select's notifier function from each registered receiver,
Necessary to prevent memory leaks in long-running receivers. This is mark the associated latch as closed, and cause any thread currently
called automatically when the Python :keyword:`with` statement is used. sleeping in :py:meth:`get` to be woken with
:py:class:`mitogen.core.LatchError`.
This is necessary to prevent memory leaks in long-running receivers. It
is called automatically when the Python :keyword:`with` statement is
used.
.. py:method:: empty () .. py:method:: empty ()
......
...@@ -236,6 +236,7 @@ class Select(object): ...@@ -236,6 +236,7 @@ class Select(object):
def close(self): def close(self):
for recv in self._receivers[:]: for recv in self._receivers[:]:
self.remove(recv) self.remove(recv)
self._latch.close()
def empty(self): def empty(self):
return self._latch.empty() return self._latch.empty()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment