Closed
Description
Please try this:
import pytest
import pytest_twisted
from twisted.internet.defer import inlineCallbacks, Deferred, gatherResults
@inlineCallbacks
def thingy():
d1 = Deferred()
d2 = Deferred()
yield gatherResults([d1, d2], consumeErrors=True)
@pytest_twisted.inlineCallbacks
def test_thingy():
result = yield thingy()
This hangs indefinitely for me when I run pytest
against it. I was having the problem with python=3.7, pytest=4.3.0 and pytest-twisted=1.9, although I initially encountered it in a context where I was running python=2.7, pytest=3.1.2, pytest-twisted=1.5.
It does not appear to make a difference what consumerErrors is set to. Of course, yielding on the deferreds sequentially and not using gatherResults works fine.
The test hangs until you CTRL-C, where you see something like this:
/usr/local/lib/python2.7/dist-packages/pytest_twisted/plugin.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
d = <Deferred at 0x7f895b2ab0e0 waiting on Deferred at 0x7f895b2ab710>
def blockon(d):
current = greenlet.getcurrent()
assert current is not gr_twisted, "blockon cannot be called from the twisted greenlet"
result = []
def cb(r):
result.append(r)
if greenlet.getcurrent() is not current:
current.switch(result)
d.addCallbacks(cb, cb)
if not result:
_result = gr_twisted.switch()
> assert _result is result, "illegal switch in blockon"
E AssertionError: illegal switch in blockon
I learned that this error message probably stemmed from an unhandled exception at this post: #4
I tried the fixture suggested recently at that post, but it did not change the problem I was having.
Metadata
Metadata
Assignees
Labels
No labels