【问题标题】:DjangoQ run manage.py qcluster results in PermissionError: [WinError5] Access is deniedDjango run manage.py q cluster 导致 PermissionError: [WinError 5] Access is denied
【发布时间】:2017-08-14 09:28:10
【问题描述】:

我最近刚开始使用 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,我也没有真正得到。

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

[编辑] 在尝试了 DjangoQ 替代品 - Celery - 我能够重新创建问题: 如果使用 Celery 4.0.2 会发生相同的错误,但不会使用 Celery 3.1.25 我还没有弄清楚如何解决这个问题,但决定暂时坚持使用 Celery,因为它有点工作......

【问题讨论】:

    标签: python django celery


    【解决方案1】:
    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
    

    【讨论】:

      猜你喜欢
      • 2020-06-20
      • 2021-01-10
      • 1970-01-01
      • 2016-07-21
      • 2022-01-25
      • 2021-03-23
      • 2020-07-22
      • 1970-01-01
      相关资源
      最近更新 更多