Skip to content
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

run (shell specific?): allow for background mode? #30

Closed
yarikoptic opened this issue May 29, 2020 · 4 comments
Closed

run (shell specific?): allow for background mode? #30

yarikoptic opened this issue May 29, 2020 · 4 comments

Comments

@yarikoptic
Copy link
Contributor

ATM qme run execution awaits for completion of the task. Being able to just submit for running the task in the background would be super useful.

@vsoch
Copy link
Owner

vsoch commented May 29, 2020

Yes but how would you implement that?

@yarikoptic
Copy link
Contributor Author

;-) good question... quick and ugly could be as

$> python -c 'import os; os.system( "bash -c \"{ sleep 4; echo done; } & disown\" " )'; echo exited; sleep 2; echo slept
exited
slept
$> done

ie qwe could just start a new one of itself (but in foreground) and detach. But I think there is a more "natural" way... we did something like that in fail2ban but I had not touched that project for so long and it changed so much that I can't quickly find... theoretically IIRC it is -- "fork into a new child subprocess; child continues; parent quits"... ha -- I said "fork" and that lead me to a new search within fail2ban to immediately find it:
https://github.com/fail2ban/fail2ban/blob/master/fail2ban/server/server.py#L842

@vsoch
Copy link
Owner

vsoch commented May 30, 2020

How would we capture the result and return code then? This could be appropriate for an executor that doesn't need those variables (and I don't think I'd use os.system, I've read somewhere that's not great practice) but not for a basic shell executor that requires them.

@vsoch
Copy link
Owner

vsoch commented May 30, 2020

I think I'm leaning on the side of being conservative with respect to using os.fork, os.system, or subprocess with shell=True, but I do think there are libraries we can try get at async, or just test using a & as a user normally would. See https://stackoverflow.com/questions/30157895/does-python-os-fork-uses-the-same-python-interpreter for some of my concerns, and let's pick up discussion around this in #2, which I've been thinking about since I started the library! Closing this issue, let's pick up in #2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants