django-q qcluster 在 运行 in Pycharm Debug 时启动和退出

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

我正在 运行与 PyCharm 中的 django-q 建立一个 Django 项目。 manage.py runserver 在一个实例中是 运行ning,而 manage.py qcluster 在另一个实例中是 运行ning。 qcluster 启动正常,然后立即正常退出。以下是全文:

/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

显然我希望它能无限期地保持 运行ning。如果我从 PyCharm 的 manage.py 终端 运行 它按预期运行。 manage.py runserver 运行 符合预期。

我的版本:

为了运行django_q在PyCharm调试中,我必须打开设置->构建、执行、部署->Python调试器,然后select Gevent compatible。我从这个问题中找到了解决方案:https://github.com/Koed00/django-q/issues/367.