Commit 105259ee authored by Josh Snyder's avatar Josh Snyder

Changes requested in review

New test, which fails without the previous commit:

    ERROR: test_wait_noiter (__main__.TestWaiting)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/vagrant/gevent/src/greentest/greentest/leakcheck.py", line 200, in wrapper
        return _RefCountChecker(self, method)(args, kwargs)
      File "/home/vagrant/gevent/src/greentest/greentest/leakcheck.py", line 184, in __call__
        self._run_test(args, kwargs)
      File "/home/vagrant/gevent/src/greentest/greentest/leakcheck.py", line 109, in _run_test
        self.function(self.testcase, *args, **kwargs)
      File "/home/vagrant/gevent/src/greentest/greentest/errorhandler.py", line 48, in wrapper
        return method(self, *args, **kwargs)
      File "/home/vagrant/gevent/src/greentest/greentest/errorhandler.py", line 35, in wrapper
        return method(self, *args, **kwargs)
      File "/home/vagrant/gevent/src/greentest/greentest/testcase.py", line 63, in wrapper
        return method(self, *args, **kwargs)
      File "src/greentest/test__wait.py", line 12, in test_wait_noiter
        ready = next(gevent.iwait((sem1, sem2)))
      File "src/gevent/_hub_primitives.py", line 149, in gevent.__hub_primitives._WaitIterator.__next__
        raise
      File "src/gevent/_hub_primitives.py", line 140, in gevent.__hub_primitives._WaitIterator.__next__
        item = self._waiter.get()
      File "src/gevent/_waiter.py", line 192, in gevent.__waiter.MultipleWaiter.get
        Waiter.get(self)
      File "src/gevent/_waiter.py", line 151, in gevent.__waiter.Waiter.get
        return self.hub.switch()
      File "src/gevent/_greenlet_primitives.py", line 59, in gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch
        def switch(self):
      File "src/gevent/_greenlet_primitives.py", line 59, in gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch
        def switch(self):
      File "src/gevent/_greenlet_primitives.py", line 63, in gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch
        return _greenlet_switch(self) # pylint:disable=undefined-variable
      File "src/gevent/__greenlet_primitives.pxd", line 35, in gevent.__greenlet_primitives._greenlet_switch
        return PyGreenlet_Switch(self, NULL, NULL)
    LoopExit: This operation would block forever
        Hub: <QuietHub '' at 0x7fc8fce60520 epoll default pending=0 ref=0 fileno=3 thread_ident=0x7fc8fffbe700>
        Handles:
    []
parent c45d212b
......@@ -10,6 +10,9 @@
- Add support for application-wide callbacks when ``Greenlet`` objects
are started. See :pr:`1289`, provided by Yury Selivanov.
- It is now possible to consume ready objects using next(gevent.iwait(objs)).
Previously such a construction would hang. See :pr:`1288`, provided by Josh
Snyder.
1.3.7 (2018-10-12)
==================
......
......@@ -55,7 +55,7 @@ cdef class _WaitIterator:
cdef bint _begun
cdef _begin(self)
cdef _cleanup(self)
cpdef iwait_on_objects(objects, timeout=*, count=*)
......
......@@ -118,6 +118,8 @@ class _WaitIterator(object):
self._begun = True
# XXX: If iteration doesn't actually happen, we
# could leave these links around!
for obj in self._objects:
obj.rawlink(self._switch)
......
import gevent
import greentest
from gevent.lock import Semaphore
class TestWaiting(greentest.TestCase):
def test_wait_noiter(self):
"""Test that gevent.iwait returns objects which can be iterated upon
without additional calls to iter()"""
sem1 = Semaphore()
sem2 = Semaphore()
gevent.spawn(sem1.release)
ready = next(gevent.iwait((sem1, sem2)))
self.assertEqual(sem1, ready)
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