python3.11 + Celery + Gevent ->“返回NULL而不设置异常”

问题描述 投票:0回答:1

当使用 python3.11 并以 Redis 作为代理在容器上运行 celery Worker 时 - 我收到以下异常。

降级到python 3.10解决了问题,但是还有其他解决方案吗?

2023-08-04 11:10:28,805] [WARNING] [Dummy-748] [log.py:232 - write()] Traceback (most recent call last):
[2023-08-04 11:10:28,806] [WARNING] [Dummy-748] [log.py:232 - write()]   File "src/gevent/_waiter.py", line 122, in gevent._gevent_c_waiter.Waiter.switch
[2023-08-04 11:10:28,806] [WARNING] [Dummy-748] [log.py:232 - write()] SystemError: <built-in method switch of gevent._gevent_cgreenlet.Greenlet object at 0x7fcdb37de700> returned NULL without setting an exception
[2023-08-04 11:10:28,806] [WARNING] [Dummy-748] [log.py:232 - write()] 2023-08-04T11:10:28Z
[2023-08-04 11:10:28,806] [WARNING] [Dummy-748] [log.py:232 - write()]
[2023-08-04 11:10:28,806] [WARNING] [Dummy-748] [log.py:232 - write()] <built-in method switch of gevent._gevent_cgreenlet.Greenlet object at 0x7fcdb37de700> failed with SystemError
[2023-08-04 11:10:28,806] [ERROR] [MainThread] [consumer.py:248 - perform_pending_operations()] Pending callback raised: SystemError('<built-in method switch of gevent._gevent_cgreenlet.Greenlet object at 0x7fcdb37de700> returned NULL without setting an exception')
Traceback (most recent call last):
  File "/home/.local/lib/python3.11/site-packages/celery/worker/consumer/consumer.py", line 246, in perform_pending_operations
    self._pending_operations.pop()()
  File "/home/.local/lib/python3.11/site-packages/vine/promises.py", line 160, in __call__
    return self.throw()
           ^^^^^^^^^^^^
  File "/home/.local/lib/python3.11/site-packages/vine/promises.py", line 157, in __call__
    retval = fun(*final_args, **final_kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.local/lib/python3.11/site-packages/kombu/message.py", line 131, in ack_log_error
    self.ack(multiple=multiple)
  File "/home/.local/lib/python3.11/site-packages/kombu/message.py", line 126, in ack
    self.channel.basic_ack(self.delivery_tag, multiple=multiple)
  File "/home/.local/lib/python3.11/site-packages/kombu/transport/virtual/base.py", line 670, in basic_ack
    self.qos.ack(delivery_tag)
  File "/home/.local/lib/python3.11/site-packages/kombu/transport/redis.py", line 379, in ack
    self._remove_from_indices(delivery_tag).execute()
  File "/home/.local/lib/python3.11/site-packages/redis/client.py", line 2120, in execute
    return conn.retry.call_with_retry(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.local/lib/python3.11/site-packages/redis/retry.py", line 46, in call_with_retry
    return do()
           ^^^^
  File "/home/.local/lib/python3.11/site-packages/redis/client.py", line 2121, in <lambda>
    lambda: execute(conn, stack, raise_on_error),
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.local/lib/python3.11/site-packages/redis/client.py", line 1975, in _execute_transaction
    self.parse_response(connection, "_")
  File "/home/.local/lib/python3.11/site-packages/redis/client.py", line 2060, in parse_response
    result = Redis.parse_response(self, connection, command_name, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.local/lib/python3.11/site-packages/redis/client.py", line 1286, in parse_response
    response = connection.read_response()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.local/lib/python3.11/site-packages/redis/connection.py", line 882, in read_response
    response = self._parser.read_response(disable_decoding=disable_decoding)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.local/lib/python3.11/site-packages/redis/connection.py", line 349, in read_response
    result = self._read_response(disable_decoding=disable_decoding)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.local/lib/python3.11/site-packages/redis/connection.py", line 359, in _read_response
    raw = self._buffer.readline()
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.local/lib/python3.11/site-packages/redis/connection.py", line 262, in readline
    self._read_from_socket()
  File "/home/.local/lib/python3.11/site-packages/redis/connection.py", line 212, in _read_from_socket
    data = self._sock.recv(socket_read_size)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.local/lib/python3.11/site-packages/gevent/_socketcommon.py", line 666, in recv
    self._wait(self._read_event)
  File "src/gevent/_hub_primitives.py", line 317, in gevent._gevent_c_hub_primitives.wait_on_socket
  File "src/gevent/_hub_primitives.py", line 322, in gevent._gevent_c_hub_primitives.wait_on_socket
  File "src/gevent/_hub_primitives.py", line 304, in gevent._gevent_c_hub_primitives._primitive_wait
  File "src/gevent/_hub_primitives.py", line 46, in gevent._gevent_c_hub_primitives.WaitOperationsGreenlet.wait
  File "src/gevent/_hub_primitives.py", line 46, in gevent._gevent_c_hub_primitives.WaitOperationsGreenlet.wait
  File "src/gevent/_hub_primitives.py", line 55, in gevent._gevent_c_hub_primitives.WaitOperationsGreenlet.wait
  File "src/gevent/_waiter.py", line 154, in gevent._gevent_c_waiter.Waiter.get
  File "src/gevent/_greenlet_primitives.py", line 61, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_greenlet_primitives.py", line 61, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_greenlet_primitives.py", line 65, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_gevent_c_greenlet_primitives.pxd", line 35, in gevent._gevent_c_greenlet_primitives._greenlet_switch
  File "src/gevent/_waiter.py", line 122, in gevent._gevent_c_waiter.Waiter.switch
SystemError: <built-in method switch of gevent._gevent_cgreenlet.Greenlet object at 0x7fcdb37de700> returned NULL without setting an exception
python redis celery
1个回答
0
投票

我不使用 Celery 库,但也遇到了这个错误。 这是我的图书馆版本:

  • 事件==22.10.2
  • 格林莱特==2.0.2
  • redis==2.10.6
  • redis-py-cluster==1.3.6

但是当我重新启动服务时,并没有出现任何错误。我不知道如何解决,害怕错误再次发生。

© www.soinside.com 2019 - 2024. All rights reserved.