-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
ValueError: Unsupported signal: 2 #42
Comments
Hi @dmwyatt, thanks for the feedback. I made a quick investigation, and it looks like this is an issue with how SIGTERM signals work on windows (i.e. they don't), reference: https://stackoverflow.com/questions/47306805/signal-sigterm-not-received-by-subprocess-on-windows I don't really know much about windows, and the links from that discussion on stack overflow seem to suggest that it's non-trivial to get this to work properly. So since I don't have a proper windows dev environment to hand, I'll need some help with this one. The relevant code is around here. |
Hi, I just got hit with the issue trying to run a "docker compose up" through poe on windows. It looks like from the def send_signal(self, sig):
"""Send a signal to the process."""
# Don't signal a process that we know has already died.
if self.returncode is not None:
return
if sig == signal.SIGTERM:
self.terminate()
elif sig == signal.CTRL_C_EVENT:
os.kill(self.pid, signal.CTRL_C_EVENT)
elif sig == signal.CTRL_BREAK_EVENT:
os.kill(self.pid, signal.CTRL_BREAK_EVENT)
else:
raise ValueError("Unsupported signal: {}".format(sig)) Considering this and the fact that a SIGTERM actually calls With a check on the platform first, that could be one way to solve it, though I have no idea if and how it would work on a more general basis. |
Actually, it might be better to send a CTRL_C_EVENT than a SIGTERM. So the code modification could look like this: # signal pass through
def handle_signal(signum, _frame):
# sigint is not handled on windows
signum = signal.CTRL_C_EVENT if self._is_windows else signum
proc.send_signal(signum)
old_signal_handler = signal.signal(signal.SIGINT, handle_signal) |
Hi @JCapul, Thanks for the investigation. That sounds reasonable. I'll add this to be TODO list for the next release. Or feel free to open a PR for it :) |
send_signal() implementation on windows only supports SIGTERM, CTRL_C_EVENT and CTRL_BREAK_EVENT Ref: nat-n#42
For a complicated, multi-threaded application that uses
zmq
, I get the following error when I Ctrl-C the application that I started using poe to run the task"poetry run python .\\main.py"
Other notes
format = "black ."
run just fine, so it has something to do with how poe is running my application.try...finally
block is terminating thezmq
context and closing several sockets...but removing those actions doesn't solve this traceback popping up.The text was updated successfully, but these errors were encountered: