Search code examples
djangopycharmpython-3.7django-q

django-q qcluster starts and exits while running in Pycharm Debug


I'm running a Django project with django-q in PyCharm. manage.py runserver is running in one instance, and manage.py qcluster is running in another. qcluster starts up fine, then immediately exits gracefully. Here is the full text:

/Users/user/PycharmProjects/project/venv/bin/python /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 65362 --file /Users/user/PycharmProjects/project/manage.py qcluster --settings=project.settings.dev
Connected to pydev debugger (build 193.6494.30)
pydev debugger: process 21339 is connecting

16:03:44 [Q] INFO Q Cluster grey-kentucky-georgia-avocado starting.
16:03:44 [Q] INFO Process-1 guarding cluster grey-kentucky-georgia-avocado
16:03:44 [Q] INFO Q Cluster grey-kentucky-georgia-avocado running.
16:03:44 [Q] INFO Process-1:1 ready for work at 21343
16:03:44 [Q] INFO Process-1:2 ready for work at 21344
16:03:44 [Q] INFO Process-1:3 ready for work at 21345
16:03:44 [Q] INFO Process-1:4 ready for work at 21346
16:03:44 [Q] INFO Process-1:5 ready for work at 21347
16:03:44 [Q] INFO Process-1:6 monitoring at 21348
16:03:44 [Q] INFO Process-1:7 pushing tasks at 21349
16:03:44 [Q] INFO Q Cluster grey-kentucky-georgia-avocado stopping.
16:03:44 [Q] INFO Process-1 stopping cluster processes
16:03:45 [Q] INFO Process-1:7 stopped pushing tasks
16:03:46 [Q] INFO Process-1:1 stopped doing work
16:03:46 [Q] INFO Process-1:2 stopped doing work
16:03:46 [Q] INFO Process-1:3 stopped doing work
16:03:46 [Q] INFO Process-1:4 stopped doing work
16:03:46 [Q] INFO Process-1:5 stopped doing work
16:03:47 [Q] INFO Process-1 waiting for the monitor.
16:03:47 [Q] INFO Process-1:6 stopped monitoring results
16:03:47 [Q] INFO Q Cluster grey-kentucky-georgia-avocado has stopped.

Process finished with exit code 0

Obviously I would like it to stay running indefinitely. If I run it from PyCharm's manage.py terminal it operates as expected. manage.py runserver runs as expected.

My versions:

  • Python 3.7
  • Django 3.0.3
  • django-q 1.2.1
  • PyCharm 2019.3.3 Pro

Solution

  • To run django_q in PyCharm Debug, I had to open Settings->Build, Execution, Deployment->Python Debugger, and select Gevent compatible. I found the solution from this issue: https://github.com/Koed00/django-q/issues/367.