Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm + Python 3.6 + Django + debugging + generators == world of pain

I have this issue for a while now where starting django's internal server (runserver) becomes near unusable because there's so many errors like this reported in the console:

Exception ignored in: <generator object SQLCompiler.setup_query.<locals>.<genexpr> at 0x2F2DE360>
Traceback (most recent call last):
  File "C:\Python36\lib\site-packages\django\db\models\sql\compiler.py", line 39, in <genexpr>
    if all(self.query.alias_refcount[a] == 0 for a in self.query.alias_map):
SystemError: error return without exception set

Basically, these are generators not consumed and Python (at least 3.5 and up) reports this into console. And there are MANY!

This basically hogs the python process serving the app as well as PyCharm process trying to display all these errors in the console view. On a bad day, the app becomes like 10% of its normal speed because of this.

I am currently lessening this problem by implementing a filter on stderr which at least makes the console output usable again. It helps with CPU usage as well, but the problem is that those exceptions still happen and trigger PyCharm's hooks. As a result, CPU usage is still high, though not insane any more.

How can I get rid of this permanently? Any interpretation of "get rid" accepted in proposed solutions.

like image 445
velis Avatar asked Jul 05 '18 11:07

velis


Video Answer


1 Answers

This seems to be an issue with PyCharm.

Try setting the environment variable PYDEVD_USE_FRAME_EVAL=NO, as suggested in this ticket on the PyCharm Issue Tracker.

like image 63
Daniel Hepper Avatar answered Oct 25 '22 21:10

Daniel Hepper