DjangoQ在PermissionError中运行manage.py qcluster结果:[WinError5]访问被拒绝

时间:2017-03-22 10:19:50

标签: python django celery

我刚刚开始使用Django开始使用Web应用程序开发,现在可以使用Django-Q进行异步任务。

我跟随this tutorial向上滑动13.不幸的是,当我尝试运行python manage.py qcluster时,我收到以下错误消息:

(djangoq_tut) D:\Code\Python\DjangoQ_Tutorial\djangoq_demo>python manage.py qcluster
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "D:\Code\Python\DjangoQ_Tutorial\djangoq_tut\lib\site-packages\django\core\management\__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "D:\Code\Python\DjangoQ_Tutorial\djangoq_tut\lib\site-packages\django\core\management\__init__.py", line 342, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "D:\Code\Python\DjangoQ_Tutorial\djangoq_tut\lib\site-packages\django\core\management\base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "D:\Code\Python\DjangoQ_Tutorial\djangoq_tut\lib\site-packages\django\core\management\base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "D:\Code\Python\DjangoQ_Tutorial\djangoq_tut\lib\site-packages\django_q\management\commands\qcluster.py", line 22, in handle
    q.start()
  File "D:\Code\Python\DjangoQ_Tutorial\djangoq_tut\lib\site-packages\django_q\cluster.py", line 57, in start
    self.sentinel.start()
  File "c:\program files (x86)\python35-32\Lib\multiprocessing\process.py", line 105, in start
    self._popen = self._Popen(self)
  File "c:\program files (x86)\python35-32\Lib\multiprocessing\context.py", line 212, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "c:\program files (x86)\python35-32\Lib\multiprocessing\context.py", line 313, in _Popen
    return Popen(process_obj)
  File "c:\program files (x86)\python35-32\Lib\multiprocessing\popen_spawn_win32.py", line 66, in __init__
    reduction.dump(process_obj, to_child)
  File "c:\program files (x86)\python35-32\Lib\multiprocessing\reduction.py", line 59, in dump
    ForkingPickler(file, protocol).dump(obj)
TypeError: can't pickle _thread.lock objects

(djangoq_tut) D:\Code\Python\DjangoQ_Tutorial\djangoq_demo>Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\program files (x86)\python35-32\Lib\multiprocessing\spawn.py", line 100, in spawn_main
    new_handle = steal_handle(parent_pid, pipe_handle)
  File "c:\program files (x86)\python35-32\Lib\multiprocessing\reduction.py", line 86, in steal_handle
    _winapi.DUPLICATE_SAME_ACCESS | _winapi.DUPLICATE_CLOSE_SOURCE)
PermissionError: [WinError 5] Access is denied

我正在使用Windows 7计算机和Python 3.5.1(32位)以及以下要求:

appdirs==1.4.3
arrow==0.10.0
blessed==1.14.1
Django==1.9
django-picklefield==0.3.2
django-q==0.7.18
future==0.16.0
packaging==16.8
pyparsing==2.2.0
python-dateutil==2.6.0
six==1.10.0
wcwidth==0.1.7

我试着查找错误的来源,它看起来像我可能不完全与Django或Django-Q相关。除此之外我不太明白这意味着什么。

还尝试使用Python 2.7.12,在virtualenv之外,我得到了TypeError: can't pickle _thread.lock objects,我也没有。{/ p>

任何想法如何解决这个问题?

[编辑] 在尝试使用DjangoQ替代品 - 芹菜之后 - 我能够重新创建问题: 如果使用Celery 4.0.2,则会出现相同的错误,但Celery 3.1.25则不会 我仍然没有想出如何解决这个问题,但我决定暂时坚持使用Celery,因为它有点有用......

1 个答案:

答案 0 :(得分:0)

Install the latest version with pip:

$ pip install django-q

Add django_q to INSTALLED_APPS in your projects settings.py:

INSTALLED_APPS = (
    # other apps
    'django_q',
)

Run Django migrations to create the database tables:

$ python manage.py migrate

Choose a message broker , configure it and install the appropriate client library.

Run Django Q cluster in order to handle tasks async:

$ python manage.py qcluster