Skip to content

Can't pass in a deferred to session.run under Python 3 #12

@mjpieters

Description

@mjpieters

The session.run() function has no path for a non-coroutine function being passed in, it'll simply return without calling twisted.react():

def run(self, f):
# Python 3 only.
if hasattr(inspect, 'iscoroutinefunction'):
# Is this a coroutine?
if inspect.iscoroutinefunction(f):
def w(reactor):
return self.wrap(f())
# If so, convert coroutine to Deferred automatically.
return task.react(w)
else:
# Otherwise, run the Deferred.
return task.react(f)

Under Python 3, line 63 is True, but if line 65 is False (so f is not a coroutine function) , the function ends. Should the else on line 70 be dropped, and lines 71 and 72 unindented?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions