Skip to content

PermissionError: [WinError 5] #422

Closed

Description

@thcpdd

When I stop the taksiq worker in the windows command line, it raise a exception 'PermissionError: [WinError 5]'.

This is my broker code:

# broker.py
from taskiq_redis import RedisAsyncResultBackend
from taskiq_aio_pika import AioPikaBroker

import settings


_mq_conf = settings.REDIS_CONF["mq"]
_redis_url = f"redis://{_mq_conf['HOST']}:{_mq_conf['PORT']}/{_mq_conf['DB']}"

broker = AioPikaBroker(
    url=settings.RABBITMQ_CONF["url"],
).with_result_backend(RedisAsyncResultBackend(redis_url=_redis_url))


@broker.task("test-task")
async def task1():
    print(1)

Test code:

import asyncio
from mq.broker import broker, task1

async def main():
    await broker.startup()
    await task1.kiq()
    await broker.shutdown()


asyncio.run(main())

Starting the taskiq worker(Using the superuser permission when opening the Windows cmd):

taskiq worker mq.broker:broker

Detail error(when I press Ctrl + C):

[2025-03-11 14:31:36,728][taskiq.process-manager][WARNING][MainProcess] Workers are scheduled for shutdown.
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "E:\SmartOJ\smartoj-backend\venv\Scripts\taskiq.exe\__main__.py", line 7, in <module>
  File "E:\SmartOJ\smartoj-backend\venv\Lib\site-packages\taskiq\__main__.py", line 73, in main
    status = command.exec(sys.argv[1:])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\SmartOJ\smartoj-backend\venv\Lib\site-packages\taskiq\cli\worker\cmd.py", line 27, in exec
    return run_worker(wargs)
           ^^^^^^^^^^^^^^^^^
  File "E:\SmartOJ\smartoj-backend\venv\Lib\site-packages\taskiq\cli\worker\run.py", line 199, in run_worker
    status = manager.start()
             ^^^^^^^^^^^^^^^
  File "E:\SmartOJ\smartoj-backend\venv\Lib\site-packages\taskiq\cli\worker\process_manager.py", line 272, in start
    os.kill(worker.pid, signal.SIGINT)
PermissionError: [WinError 5] 拒绝访问。

My device information:
Platform: Windows 11
Python version: Python 3.11.2
Taskiq version: 0.11.13

Activity

  1. s3rius commented on Mar 11, 2025

    @s3rius
    Member

    This happens because of permissions on your account.

    Seems like os.kill operation is restricted for your user.

    https://stackoverflow.com/a/6688913

    Try fixing your user's permissions.

  2. thcpdd commented on Mar 13, 2025

    @thcpdd
    Author

    This happens because of permissions on your account.

    Seems like os.kill operation is restricted for your user.

    https://stackoverflow.com/a/6688913

    Try fixing your user's permissions.

    Thank you for your sugesstion.
    I have found many problems with Windows platform. There is no problem using it on Linux platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions