-
-
Notifications
You must be signed in to change notification settings - Fork 503
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
_bg doesn't work if not being assigned #139
Comments
Are you running this in a python shell by chance? The python shell will try to evaluate the return value of a function, if you're not assigning it to a variable, thereby causing sleep to block. |
Yes, I am. Ok, that makes sense, thanks. Is there any way to get a background process started by sh to persist after the python program has ended? I get "Exception in thread Thread-1 (most likely raised during interpreter shutdown)". |
So I looked at the code. It should be possible, in theory, to do: import sh
sh.nohup.sleep(60, _bg=True) And a sleep process should exist in the background. The problem is this line, which adds the spawned process to a list of processes to be killed on script exit, if If you want to add this for yourself and everyone else, I would remove the import sh
sh.nohup.sleep(60, _bg=True, _persist=True) |
I've decided not to use sh after all but rather to rework my code so I don't have to shell out in the first place, so I'm not going to bother. Sorry... |
spawned processes now persist after exit by default and ignore SIGHUP |
Unfortunately, this change seems to make foreground subprocesses persist after the Python sh process as well as background, which is very surprising compared with /bin/sh. |
The text was updated successfully, but these errors were encountered: