-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
problem with run async=true & returncodes ..... #55
Comments
You haven't specified any information about OS, etc. This script works for me, on Ubuntu 64-bit (Linux Mint): import sarge
cmd = 'echo "Hello " && sleep 2 && echo "Finish " '
p = sarge.run(cmd, async_=True)
p.wait() # wait for pipeline to finish
print(p.returncodes) Running it prints:
So I plan to close this unless you can come up with more information and/or a small example demonstrating a problem. |
Hi import sarge
cmd = 'echo "Hello " && sleep 2 && echo "Finish " '
p = sarge.run(cmd, async_=True)
for i in range(1, 20):
sleep(0.5)
print('CMD:', p.commands, sep='')
print('Count:', len(p.returncodes), ' ret:', p.returncodes, sep='') I use it in async flow, then wait not suitable Archlinux (lastest) |
Then you can use import sarge
import time
cmd = 'echo "Hello " && sleep 2 && echo "Finish " '
p = sarge.run(cmd, async_=True)
for i in range(1, 20):
time.sleep(0.5)
rcs = p.poll_all()
if i == 1:
print('cmd:', p.commands, sep='')
print('%d: return codes: %s' % (i, rcs), sep='')
if None not in rcs:
break prints
|
Thx ... But you think behavior of returncodes is True ?? and with async_=True the "returncodes" in this sample without wait return none for infinite ?? |
Yes, because the |
then loop terminate with wrong "returncodes" ?? from API : I think one of it is wrong : (one)API comment is wrong OR (TWO)returncodes behavior |
What exactly do you think is wrong? |
in First example in async mode run it : the command i think return with [0, 0, 0] after 2 second |
What happens if you use See this part of the documentation for |
as your comment : Popen.returncode
focus in : A None value indicates that the process hasn’t terminated yet then sarge returncodes in async mode return wrong value because operation successfully finish ! seems your returncodes must fixed in async mode specially when have && and sleep |
It can also indicate that you haven't checked the status of the process - even if just using I just realised that the documentation for |
If you are using |
Two things need to happen for a
|
why returncodes internally not call poll_all specially in async mode ? this do latest return state ... |
Generally in this kind of code you don't assume too much about what the caller wants, but provide mechanisms for them to do it. I could change it to call |
I have no strong objection to changing it to poll the individual subprocesses, though. |
Well, I did it the way I did it because I wanted to let the users of the library decide when they want to do certain stuff. Your feedback is that you think it is too inconvenient to call |
clear code in better always :-) |
Thanks for helping to make |
Hi
below code always return [0, 0, None] and command never finish :
seems have problem with sleep ...
The text was updated successfully, but these errors were encountered: