Repository navigation
Exception 'signal only works in main thread' when Connection.run command with pty=True #2204
Description
Activity
- added 9 commits that reference this issue
on Mar 28, 2022 - added a commit that references this issue
on Mar 28, 2022 Quite annoying bug, have to rollback from 2.7.0 on 2.6.0.
Environment - python:3.9-slim docker container.Reacted by Crux-OneWe are seeing a similar
signal only works in main threadregression in behaviour in 2.7 when invoking.runwith"warn": True, "echo": True, "pty": True,Fabric 2.6.0 worked without issue.
In both cases we were using python 3.8.
Reacted by Nicolas Legrand and Crux-OneHello, is there any update on a potential fix for this issue? Thank you!
v2.7 likely contains bugs.
Here is my Pipfile. It works.[packages] fabric = "==2.6" [requires] python_version = "3.9.9"
Same issue on python 3.9
Hello, is there any update on the patch?
I use fabric as a library, and was able to get around this by monkey patching the problematic part:
from invoke.terminals import pty_size from fabric.main import Argument, Config, Executor, Fab def patched_start(self, command, shell, env, timeout=None): self.channel = self.context.create_session() if self.using_pty: cols, rows = pty_size() self.channel.get_pty(width=cols, height=rows) # NOTE: Everything else is the same except for these two commented lines # if hasattr(signal, "SIGWINCH"): # signal.signal(signal.SIGWINCH, self.handle_window_change) if env: if self.inline_env: parameters = " ".join(["{}={}".format(k, v) for k, v in sorted(env.items())]) command = "export {} && {}".format(parameters, command) else: self.channel.update_environment(env) self.send_start_message(command) class MyProgram(Fab): def update_config(self): # This lets us patch Remote.start with the function above self.config.runners.remote.start = patched_start super().update_config() program = MyProgram( name="Fabric", version="1.0.0", executor_class=Executor, config_class=Config, ) sys.exit(program.run())
Ran into this on CircleCI while fixing a related issue - it looks like the simple check of "are we the main thread?" is sufficient to avoid the problem.
That fix will be released imminently in Fabric 3.2.2.
- added 4 commits that reference this issue
on Aug 31, 2023
Describe the bug
When running a command with Connection.run and argument pty=True in a thread we get that error. fabric version 2.7.0
To Reproduce
Steps to reproduce the behaviour (please attach a minimal example):
Running the code below on fabric 2.6.0 everything work fine, while if it is run with 2.7.0 it fails due to this line
fabric/fabric/runners.py
Line 46 in 8a93369
Expected behaviour
fabric works within a thread
Environment
Bug seen in python 3.7.2 and 3.10.1
alternative interpreter such as PyPy?
appeared? 2.6.0 work fine
copy of your code, the command you used to invoke it, and the full output of
your run (if applicable.)