pyinfra-dev / pyinfra

pyinfra turns Python code into shell commands and runs them on your servers. Execute ad-hoc commands and write declarative operations. Target SSH servers, local machine and Docker containers. Fast and scales from one server to thousands.
https://pyinfra.com
MIT License
3.91k stars 382 forks source link

Gevent / invoke compatibility & support for `Match exec` SSH config #574

Closed Fizzadar closed 2 years ago

Fizzadar commented 3 years ago

Describe the bug

Origin: https://github.com/Fizzadar/pyinfra/issues/569

Essentially gevent monkey patching of thread & subprocess modules breaks using invoke, which [paramiko uses to implement Match exec statements in SSH config]().

This looks the same as: https://github.com/gevent/gevent/issues/1268

To Reproduce

Put the following in SSH config:

Match exec echo

Then try to use pyinfra with a SSH target and get lots of error spam w/:

BlockingIOError: [Errno 35] Resource temporarily unavailable

Expected behaviour

It shouldn't error! Unsure on how to fix this, or whether it's possible.

Fizzadar commented 2 years ago

I figured out a fix for this - it's pretty horrible but gets the job done, and beats the current exception that is raised: https://github.com/Fizzadar/pyinfra/commit/a7964e525a9c632b1d7b515c6a85cdaf749c342c.

Released in v1.6.2.