Commit 24e7e819 authored by Jason Madden's avatar Jason Madden

Deal gracefully with passing None watchers to hub.cancel_wait, something that...

Deal gracefully with passing None watchers to hub.cancel_wait, something that may be more common now that we try to destroy watchers ASAP for GC reasons. Fixes #1089.
parent e43ecb2e
......@@ -35,6 +35,10 @@
- Add the ``dnspython`` resolver as a lightweight alternative to
c-ares. See :pr:`1088`.
- Fix calling ``shutdown`` on a closed socket. It was raising
``AttributeError``, now it once again raises the correct
``socket.error``. Reported in :issue:`1089` by André Cimander.
1.3a1 (2018-01-27)
==================
......
......@@ -679,8 +679,15 @@ class Hub(RawGreenlet):
.. versionchanged:: 1.3a1
Added the *close_watcher* parameter. If true, the watcher
will be closed after the exception is thrown.
will be closed after the exception is thrown. The watcher should then
be discarded. Closing the watcher is important to release native resources.
.. versionchanged:: 1.3a2
Allow the *watcher* to be ``None``. No action is taken in that case.
"""
if watcher is None:
# Presumably already closed.
# See https://github.com/gevent/gevent/issues/1089
return
if watcher.callback is not None:
self.loop.run_callback(self._cancel_wait, watcher, error, close_watcher)
elif close_watcher:
......
......@@ -439,5 +439,15 @@ class TestFunctions(greentest.TestCase):
self.assertMonkeyPatchedFuncSignatures('socket', exclude=exclude)
class TestSocket(greentest.TestCase):
def test_shutdown_when_closed(self):
# https://github.com/gevent/gevent/issues/1089
# we once raised an AttributeError.
s = socket.socket()
s.close()
with self.assertRaises(socket.error):
s.shutdown(socket.SHUT_RDWR)
if __name__ == '__main__':
greentest.main()
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