Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't debug locust script with python 3.12

Tags:

python

locust

I'm using locust 2.29.1 for my performance tests.

It works fine on Python 3.11.8 but now I'm trying to move to Python 3.12.4 and can't debug because it's freezing on the line with import locust. Gevent compatible in PyCharm settings is checked. And I don't have any exceptions during script running.

Here is the error output:

Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/path/to/project/.venv/lib/python3.12/site-packages/locust/__init__.py", line 19, in <module>
    from .contrib.fasthttp import FastHttpUser
  File "<frozen importlib._bootstrap>", line 471, in _lock_unlock_module
  File "<frozen importlib._bootstrap>", line 365, in acquire
KeyboardInterrupt
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1551, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/path/to/project/src/scripts/locustfile.py", line 3, in <module>
    import locust
  File "<frozen importlib._bootstrap>", line 1357, in _find_and_load
  File "<frozen importlib._bootstrap>", line 421, in __exit__
  File "<frozen importlib._bootstrap>", line 376, in release
RuntimeError: cannot release un-acquired lock
python-BaseException

In the locust documentation, I didn't find any suggestions.

like image 893
vuklip Avatar asked Apr 11 '26 11:04

vuklip


1 Answers

Try these steps to get rid of the problem:

  1. in Settings (Ctrl+Alt+S) -> type "Python Debugger" in the search field -> enable "Gevent Compatible".

  2. in Actions (Ctrl+Shift+A) -> type "Registry..." -> disable "python.debug.low.impact.monitoring.api".
    And retry debugging.

It helped me. Debug is working again now.

like image 67
Siarhei Litvinchuk Avatar answered Apr 13 '26 01:04

Siarhei Litvinchuk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!