pyinvoke / invoke

Pythonic task management & command execution.
http://pyinvoke.org
BSD 2-Clause "Simplified" License
4.38k stars 367 forks source link

Printing Promise objects from asynchronous Runner.run() raises Attribute Error #996

Open dqian3 opened 4 months ago

dqian3 commented 4 months ago
@task
def test(c):
    promise = c.run("sleep 5", asynchronous=True)
    print(promise)
    promise.join()

As a new user of invoke, I noticed that when I would try to print the promise returned by a Runner.run call with asynchronous=True (see above code for an example), I would get the following error:

AttributeError: 'Promise' object has no attribute 'exited'

Looking at runners.py, it seems the issue is that since Promise is a subclass of Result, and so inherits its __str__ method.