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.85k stars 374 forks source link

Cannot debug code in PyCharm #450

Closed mjmare closed 3 years ago

mjmare commented 3 years ago

I was trying to debug some deploy code in PyCharm and put a breakpoint in the code. I got this error message which is not very informative to me:

Connected to pydev debugger (build 202.7660.27)
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 152, in __exit__
  File "<frozen importlib._bootstrap>", line 107, in release
RuntimeError: cannot release un-acquired lock
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 107, in release
RuntimeError: cannot release un-acquired lock
python-BaseException

The code was basically the example on https://docs.pyinfra.com/en/1.x/modules/python.html (see also #449).

Fizzadar commented 3 years ago

I'm not sure how to handle this as I don't know where the locking is coming from. It might be that you need to explicitly enable gevent => https://blog.jetbrains.com/pycharm/2012/08/gevent-debug-support/?

mjmare commented 3 years ago

Wow, you nailed it! Set: Settings | Python Debugger | Gevent compatible debugging to ON. Learned something today.

Fizzadar commented 3 years ago

Excellent! I'm going to add a note about this on the compatability doc (and link to that doc from help & support).

Fizzadar commented 3 years ago

https://github.com/Fizzadar/pyinfra/commit/1401e704158601e2ffa206cb5f11726747a64a8e

rtoton commented 6 months ago

how setup debugging, i can't find info about this