Error: PermissionError(13, 'Access is denied', None, 5, None)

I have this error while working with celery

[2024-10-06 14:38:15,464: ERROR/SpawnPoolWorker-3] Pool process <billiard.pool.Worker object at 0x0000016C0BBF5A00> error: PermissionError(13, 'Access is denied', None, 5, None)
Traceback (most recent call last):
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\billiard\pool.py", line 473, in receive
    ready, req = _receive(1.0)
                 ^^^^^^^^^^^^^
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\billiard\pool.py", line 445, in _recv
    return True, loads(get_payload())
                       ^^^^^^^^^^^^^
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\billiard\queues.py", line 394, in get_payload    with self._rlock:
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\billiard\synchronize.py", line 115, in __enter__
    return self._semlock.__enter__()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [WinError 5] Access is denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\billiard\pool.py", line 351, in workloop
    req = wait_for_job()
          ^^^^^^^^^^^^^^
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\billiard\pool.py", line 480, in receive
    raise SystemExit(EX_FAILURE)
SystemExit: 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\billiard\pool.py", line 292, in __call__
    sys.exit(self.workloop(pid=pid))
             ^^^^^^^^^^^^^^^^^^^^^^
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\billiard\pool.py", line 396, in workloop
    self._ensure_messages_consumed(completed=completed)
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\billiard\pool.py", line 406, in _ensure_messages_consumed
    if self.on_ready_counter.value >= completed:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 3, in getvalue
PermissionError: [WinError 5] Access is denied
[2024-10-06 14:38:15,464: ERROR/SpawnPoolWorker-3] Pool process <billiard.pool.Worker object at 0x0000016C0BBF5A00> error: PermissionError(13, 'Access is denied', None, 5, None)
Traceback (most recent call last):
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\billiard\pool.py", line 473, in receive
    ready, req = _receive(1.0)
                 ^^^^^^^^^^^^^
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\billiard\pool.py", line 445, in _recv
    return True, loads(get_payload())
                       ^^^^^^^^^^^^^
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\billiard\queues.py", line 394, in get_payload    with self._rlock:
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\billiard\synchronize.py", line 115, in __enter__
    return self._semlock.__enter__()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [WinError 5] Access is denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\billiard\pool.py", line 351, in workloop
    req = wait_for_job()
          ^^^^^^^^^^^^^^
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\billiard\pool.py", line 480, in receive
    raise SystemExit(EX_FAILURE)
SystemExit: 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\billiard\pool.py", line 292, in __call__
    sys.exit(self.workloop(pid=pid))
             ^^^^^^^^^^^^^^^^^^^^^^
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\billiard\pool.py", line 396, in workloop
    self._ensure_messages_consumed(completed=completed)
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\billiard\pool.py", line 406, in _ensure_messages_consumed
    if self.on_ready_counter.value >= completed:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 3, in getvalue
PermissionError: [WinError 5] Access is denied
[2024-10-06 14:38:15,642: ERROR/MainProcess] Process 'SpawnPoolWorker-3' pid:19032 exited with 'exitcode 1'
[2024-10-06 14:38:16,108: INFO/SpawnPoolWorker-9] child process 160 calling self.run()
[2024-10-06 14:38:23,846: INFO/MainProcess] Events of group {task} enabled by remote.
[2024-10-06 14:41:05,702: WARNING/MainProcess] consumer: Connection to broker lost. Trying to re-establish the connection...
Traceback (most recent call last):
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\celery\worker\consumer\consumer.py", line 340, in start
    blueprint.start(self)
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\celery\bootsteps.py", line 116, in start
    step.start(parent)
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\celery\worker\consumer\consumer.py", line 746, in start
    c.loop(*c.loop_args())
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\celery\worker\loops.py", line 130, in synloop    connection.drain_events(timeout=2.0)
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\kombu\connection.py", line 341, in drain_events
    return self.transport.drain_events(self.connection, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\kombu\transport\pyamqp.py", line 171, in drain_events
    return connection.drain_events(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\amqp\connection.py", line 526, in drain_events
    while not self.blocking_read(timeout):
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\amqp\connection.py", line 531, in blocking_read
    frame = self.transport.read_frame()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\amqp\transport.py", line 294, in read_frame
    frame_header = read(7, True)
                   ^^^^^^^^^^^^^
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\amqp\transport.py", line 637, in _read
    raise OSError('Server unexpectedly closed connection')
OSError: Server unexpectedly closed connection
[2024-10-06 14:41:05,780: WARNING/MainProcess] D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\celery\worker\consumer\consumer.py:391: CPendingDeprecationWarning:
In Celery 5.1 we introduced an optional breaking change which
on connection loss cancels all currently executed tasks with late acknowledgement enabled.
These tasks cannot be acknowledged as the connection is gone, and the tasks are automatically redelivered
back to the queue. You can enable this behavior using the worker_cancel_long_running_tasks_on_connection_loss
setting. In Celery 5.1 it is set to False by default. The setting will be set to True by default in Celery 6.0.

  warnings.warn(CANCEL_TASKS_BY_DEFAULT, CPendingDeprecationWarning)

[2024-10-06 14:41:05,788: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672//
[2024-10-06 14:41:05,798: INFO/MainProcess] mingle: searching for neighbors
[2024-10-06 14:41:06,826: INFO/MainProcess] mingle: all alone
[2024-10-06 14:44:05,784: WARNING/MainProcess] consumer: Connection to broker lost. Trying to re-establish the connection...
Traceback (most recent call last):
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\celery\worker\consumer\consumer.py", line 340, in start
    blueprint.start(self)
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\celery\bootsteps.py", line 116, in start
    step.start(parent)
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\celery\worker\consumer\consumer.py", line 746, in start
    c.loop(*c.loop_args())
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\celery\worker\loops.py", line 130, in synloop    connection.drain_events(timeout=2.0)
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\kombu\connection.py", line 341, in drain_events
    return self.transport.drain_events(self.connection, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\kombu\transport\pyamqp.py", line 171, in drain_events
    return connection.drain_events(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\amqp\connection.py", line 526, in drain_events
    while not self.blocking_read(timeout):
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\amqp\connection.py", line 531, in blocking_read
    frame = self.transport.read_frame()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\amqp\transport.py", line 294, in read_frame
    frame_header = read(7, True)
                   ^^^^^^^^^^^^^
  File "D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\amqp\transport.py", line 637, in _read
    raise OSError('Server unexpectedly closed connection')
OSError: Server unexpectedly closed connection
[2024-10-06 14:44:33,538: WARNING/MainProcess] D:\study\learning-python\back-end\ecommerce\venv\Lib\site-packages\celery\worker\consumer\consumer.py:391: CPendingDeprecationWarning:
In Celery 5.1 we introduced an optional breaking change which
on connection loss cancels all currently executed tasks with late acknowledgement enabled.
These tasks cannot be acknowledged as the connection is gone, and the tasks are automatically redelivered
back to the queue. You can enable this behavior using the worker_cancel_long_running_tasks_on_connection_loss
setting. In Celery 5.1 it is set to False by default. The setting will be set to True by default in Celery 6.0.

  warnings.warn(CANCEL_TASKS_BY_DEFAULT, CPendingDeprecationWarning)

this is the full error message, I am providing it to better understand the problem I am using cmd with administration access, but it didn't work out I am using Django with celery with RabbitMQ to build a asynchronous tasks to send emails to the clients.

I have tryed to make the cmd is administration as I have mentioned, I am making just two tasks with celery but it gives me this error.

I was getting the same error but after installing gevent and adding gevent in the command it is working for me.

pip install gevent

celery -A myproject worker --loglevel=info -P gevent

Back to Top