-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Code executed via conda run
does not exit on interrupt
#11420
Comments
I cannot reproduce this with a simple sleep/print script, I used the following: from time import sleep
for i in range(100):
sleep(2)
print(f"hello {i}") |
@Samreay Can you please provide a sample code as asked here microsoft/vscode-python#18700 (comment)? |
Hi team! Ive done a bunch of digging to make the smallest possible reproduction and it turns out the issue must come from some difference in process termination between python handling the interrupt and conda interrupt and how that interacts with the This file will reproduce: import time
import ray
def main():
while True:
print("Hello World!")
time.sleep(1)
if __name__ == "__main__":
ray.init()
main() And here is the difference in behaviour between python and contra interrupts: (base) sh@ARENKO-024 condatest % python reproduce.py
Hello World!
Hello World!
^CTraceback (most recent call last):
File "reproduce.py", line 13, in <module>
main()
File "reproduce.py", line 8, in main
time.sleep(1)
KeyboardInterrupt
(base) sh@ARENKO-024 condatest % conda run -n base --no-capture-output --live-stream python /Users/sh/Projects/condatest/reproduce.py
Hello World!
Hello World!
^C
CondaError: KeyboardInterrupt
(base) sh@ARENKO-024 condatest % Hello World!
Hello World!
Hello World!
ps aux | grep reproduce.pyHello World!
ps aux | grep reproduce.py
Hello World!
sh 87838 0.0 0.0 34132084 868 s000 R+ 10:19am 0:00.00 grep reproduce.py
sh 87771 0.0 0.4 36569276 73096 s000 S 10:19am 0:00.78 python /Users/sh/Projects/condatest/reproduce.py
(base) sh@ARENKO-024 condatest % Hello World!
killHello World!
Hello World!
Hello World!
Hello World!
87771
*** SIGTERM received at time=1650413974 ***
PC: @ 0x7ff81f06fe4a (unknown) __select
[2022-04-20 10:19:34,450 E 87771 785212] logging.cc:321: *** SIGTERM received at time=1650413974 ***
(base) sh@ARENKO-024 condatest % [2022-04-20 10:19:34,451 E 87771 785212] logging.cc:321: PC: @ 0x7ff81f06fe4a (unknown) __select There is a second or two when the python-handled interrupt calls the |
Hi there, thank you for your contribution! This issue has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further activity occurs. If you would like this issue to remain open please:
NOTE: If this issue was closed prematurely, please leave a comment. Thanks! |
@Samreay has provided the reproducer just above, labels not updated after that. |
What happened?
Originally reported by @Samreay in microsoft/vscode-python#18700
Then cmd-c to interrupt. Gets back to terminal, but unlike interrupting python code, the conda executable still runs in the background:
ps aux
, which means every time I want to stop the running file, I cmd-c, runps aux | grep python
, find the services which aren't stopped, and thenkill
their PIDs manually. Me killing it:Conda Details
conda info
conda list
The text was updated successfully, but these errors were encountered: