You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a CommandManager is created, it sets the interrupt signal handler to self._handle_siginthere, which replaces any previously set handler (see docs).
When running a command synchronously, self._handle_sigint is implemented via asyncio even outside of async context. Sending a kill -INT pid results in
/metaflow/metaflow/runner/subprocess_manager.py:288: RuntimeWarning: coroutine 'CommandManager.kill' was never awaited
self.cleanup()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
The async function never gets called (except on program exit i think). Also due to blocking impl here, the SubprocessManager.commands doesn't get populated. Due to both of these issues individually, the subprocess doesn't receive any signals. When sending a ctrl-c, the terminal dispatches the signal to all subprocesses (tested on iterm2 with zsh and foot with zsh), this still results in the RuntimeWarning.
In an async context, calling asyncio.create_task without awaiting on it (which is impossible due to a synchronous signal handler), doesn't actually run the task until exit (at least with my testing code). According to asyncio docs, only a signal handler registered via loop.add_signal_handler can interact with the event loop itself. I assume calling asyncio.create_task which internally uses the current event loop is considered an interaction.
Even if that worked, when running multiple commands with async_run_command, each call would replace the previous signal handler, leaving only one active (likely for the last call made).
E: According to posix spec, ctrl-c sends a special INTR character, which Generates a SIGINT signal which is sent to all processes in the foreground process group.
testing scripts:
sleep.py
importtimeimportsignaldefhandler(signum, frame):
print("Signal handler called with signal", signum)
exit(0)
signal.signal(signal.SIGINT, handler)
signal.signal(signal.SIGTERM, handler)
time.sleep(10)
When a
CommandManager
is created, it sets the interrupt signal handler toself._handle_sigint
here, which replaces any previously set handler (see docs).When running a command synchronously,
self._handle_sigint
is implemented via asyncio even outside of async context. Sending akill -INT pid
results inThe async function never gets called (except on program exit i think). Also due to blocking impl here, the
SubprocessManager.commands
doesn't get populated. Due to both of these issues individually, the subprocess doesn't receive any signals. When sending actrl-c
, the terminal dispatches the signal to all subprocesses (tested on iterm2 with zsh and foot with zsh), this still results in theRuntimeWarning
.In an async context, calling
asyncio.create_task
without awaiting on it (which is impossible due to a synchronous signal handler), doesn't actually run the task until exit (at least with my testing code). According to asyncio docs, only a signal handler registered vialoop.add_signal_handler
can interact with the event loop itself. I assume callingasyncio.create_task
which internally uses the current event loop is considered an interaction.Even if that worked, when running multiple commands with
async_run_command
, each call would replace the previous signal handler, leaving only one active (likely for the last call made).E: According to posix spec,
ctrl-c
sends a specialINTR
character, whichGenerates a SIGINT signal which is sent to all processes in the foreground process group
.testing scripts:
sleep.py
main.py
The text was updated successfully, but these errors were encountered: