在 Windows 10 中用芹菜执行花时出错

error executing flower with celery in Windows 10

我正在 windows 10.

中使用 Django 3 开发应用程序

我已经安装了 celery 和 RabitMQ 以及 flower。芹菜效果很好,但是当我 运行

celery -A proj flower

产生以下错误

[I 200718 21:32:31 command:134] Visit me at http://localhost:5555
[I 200718 21:32:31 command:141] Broker: amqp://guest:**@localhost:5672//
[I 200718 21:32:31 command:142] Registered tasks:
    ['apps.tareas.task.send_emails_users',
     'celery.accumulate',
     'celery.backend_cleanup',
     'celery.chain',
     'celery.chord',
     'celery.chord_unlock',
     'celery.chunks',
     'celery.group',
     'celery.map',
     'celery.starmap']
Traceback (most recent call last):
  File "C:\Program Files\Python38\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python38\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\Sofia\OneDrive\Proyectos\Django 3\shop\env\Scripts\celery.exe\__main__.py", line 9, in <module>
  File "c:\users\sofia\onedrive\proyectos\django 3\shop\env\lib\site-packages\celery\__main__.py", line 16, in main
    _main()
  File "c:\users\sofia\onedrive\proyectos\django 3\shop\env\lib\site-packages\celery\bin\celery.py", line 322, in main
    cmd.execute_from_commandline(argv)
  File "c:\users\sofia\onedrive\proyectos\django 3\shop\env\lib\site-packages\celery\bin\celery.py", line 495, in execute_from_commandline
    super(CeleryCommand, self).execute_from_commandline(argv)))
  File "c:\users\sofia\onedrive\proyectos\django 3\shop\env\lib\site-packages\celery\bin\base.py", line 305, in execute_from_commandline
    return self.handle_argv(self.prog_name, argv[1:])
  File "c:\users\sofia\onedrive\proyectos\django 3\shop\env\lib\site-packages\celery\bin\celery.py", line 487, in handle_argv
    return self.execute(command, argv)
  File "c:\users\sofia\onedrive\proyectos\django 3\shop\env\lib\site-packages\celery\bin\celery.py", line 415, in execute
[I 200718 21:32:31 mixins:229] Connected to amqp://guest:**@127.0.0.1:5672//
    return cls(
  File "c:\users\sofia\onedrive\proyectos\django 3\shop\env\lib\site-packages\flower\command.py", line 51, in run_from_argv
    flower.start()
  File "c:\users\sofia\onedrive\proyectos\django 3\shop\env\lib\site-packages\flower\app.py", line 50, in start
    self.listen(self.options.port, address=self.options.address,
  File "c:\users\sofia\onedrive\proyectos\django 3\shop\env\lib\site-packages\tornado\web.py", line 2042, in listen
    server.listen(port, address)
  File "c:\users\sofia\onedrive\proyectos\django 3\shop\env\lib\site-packages\tornado\tcpserver.py", line 144, in listen
    self.add_sockets(sockets)
  File "c:\users\sofia\onedrive\proyectos\django 3\shop\env\lib\site-packages\tornado\tcpserver.py", line 157, in add_sockets
    self._handlers[sock.fileno()] = add_accept_handler(
  File "c:\users\sofia\onedrive\proyectos\django 3\shop\env\lib\site-packages\tornado\netutil.py", line 268, in add_accept_handler
    io_loop.add_handler(sock, accept_handler, IOLoop.READ)
  File "c:\users\sofia\onedrive\proyectos\django 3\shop\env\lib\site-packages\tornado\platform\asyncio.py", line 79, in add_handler
    self.asyncio_loop.add_reader(
  File "C:\Program Files\Python38\lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError 

不会导致此错误。

我搜索了文档,没有发现类似这个错误。

我已经通过在 tornado\platform 中编辑文件 asyncio.py 添加:

解决了这个问题
import sys

if sys.platform == 'win32':
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

我有同样的错误。 您使用哪个版本的 python?我的是 3.8 然后我改为 3.6 一切正常。