Skip to content
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

Fabric 3.0.0 locks main thread until timeout finish #2241

Closed
puerkito66 opened this issue Jan 25, 2023 · 4 comments
Closed

Fabric 3.0.0 locks main thread until timeout finish #2241

puerkito66 opened this issue Jan 25, 2023 · 4 comments
Labels
Awaiting feedback Contributor needs to supply extra information Needs investigation

Comments

@puerkito66
Copy link

puerkito66 commented Jan 25, 2023

Fabric 3.0.0 prevents the interpreter to exit if a timeout was specified when running a remote command

For example this small script:

import fabric
import sys

conn = fabric.Connection("localhost", user="ubuntu", connect_kwargs={"key_filename":"key"})
sys.exit(conn.run("whoami", hide=True, warn=True, timeout=30)

will generate the following output:

Command exited with status 0.
=== stdout ===
ubuntu

(no stderr)

but the interpreter will hang until the the timeout.
Hitting ctrl-C while hanging generates the following traceback:

Exception ignored in: <module 'threading' from '/usr/lib/python3.9/threading.py'>
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 1428, in _shutdown
    lock.acquire()
KeyboardInterrupt:

This happens no matter the server we connect.

This is a special problem since there are some commands that needs a huge timeout windows, and if the commands executes relatively fast, the program won't finish until the timeout is acomplished.

Expected behaviour
Program finish inmediatly

Environment
Python 3.9
Ubuntu Linux 5.4.0-126-generic #142-Ubuntu
Fabric 3.0.0
Paramiko 3.0.0
Invoke 2.0.0

@DamonHolland
Copy link

DamonHolland commented Apr 4, 2023

I am observing this issue as well. A timer thread is being held until the timeout expires, even when the command has finished within the allotted window.

A threading.enumerate() call at the end of main function results with [<_MainThread(MainThread, started 10828)>, <Timer(Thread-3, started 10292)>].

The Timer thread is generated from within fabric when using timeout parameter.

PR #2242 has resolved the issue on my end.

@davidjmemmett
Copy link
Contributor

Fabric3 is an unmaintained, unofficial fork. Please retry using fabric v2.

@davidjmemmett davidjmemmett added the Awaiting feedback Contributor needs to supply extra information label Apr 7, 2023
@puerkito66
Copy link
Author

puerkito66 commented Apr 8, 2023

@davidjmemmett I'm aware of the fork of Fabric3 and since 2018 is not longer maintenaed.

But nobody is talking about that fork.
The issue described above is in this repo, which latest release of this very project is tagged as 3.0.0

https://github.com/fabric/fabric/releases/tag/3.0.0

@bitprophet
Copy link
Member

Will be fixed in next bugfix release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting feedback Contributor needs to supply extra information Needs investigation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants