Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Litestar Logging in Python3.12: Unable to configure handler 'queue_listener' (Pycharm Debugger) #3647

Closed
1 of 4 tasks
Rey092 opened this issue Jul 25, 2024 · 1 comment
Labels
Bug 🐛 This is something that is not working as expected

Comments

@Rey092
Copy link

Rey092 commented Jul 25, 2024

Description

Same as #2469
But only for pycharm debugger. Regular runner works fine.

URL to code causing the issue

No response

MCVE

from litestar import Litestar, get


@get("/")
async def index() -> str:
    return "Hello, world!"


@get("/books/{book_id:int}")
async def get_book(book_id: int) -> dict[str, int]:
    return {"book_id": book_id}


app = Litestar([index, get_book])

Steps to reproduce

1. Python 3.12
2. Run MCVE with pycharm debugger

Screenshots

No response

Logs

Traceback (most recent call last):
  File "/opt/pycharm-2024.1.1/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_pep_669_tracing.py", line 233, in py_start_callback
    if py_db._finish_debugging_session:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'PyDB' object has no attribute '_finish_debugging_session'. Did you mean: 'finish_debugging_session'?
Traceback (most recent call last):
  File "/opt/pycharm-2024.1.1/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_pep_669_tracing.py", line 233, in py_start_callback
    if py_db._finish_debugging_session:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'PyDB' object has no attribute '_finish_debugging_session'. Did you mean: 'finish_debugging_session'?
Traceback (most recent call last):
  File "/opt/pycharm-2024.1.1/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_pep_669_tracing.py", line 233, in py_start_callback
    if py_db._finish_debugging_session:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'PyDB' object has no attribute '_finish_debugging_session'. Did you mean: 'finish_debugging_session'?
Traceback (most recent call last):
  File "/opt/pycharm-2024.1.1/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_pep_669_tracing.py", line 517, in py_raise_callback
    or py_db.stop_on_failed_tests)
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'PyDB' object has no attribute 'stop_on_failed_tests'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/opt/pycharm-2024.1.1/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_pep_669_tracing.py", line 517, in py_raise_callback
    or py_db.stop_on_failed_tests)
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'PyDB' object has no attribute 'stop_on_failed_tests'
Original exception was:
Traceback (most recent call last):
  File "/opt/pycharm-2024.1.1/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_pep_669_tracing.py", line 517, in py_raise_callback
    or py_db.stop_on_failed_tests)
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'PyDB' object has no attribute 'stop_on_failed_tests'
Exception ignored in: <module 'threading' from '/usr/lib/python3.12/threading.py'>
Traceback (most recent call last):
  File "/opt/pycharm-2024.1.1/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_pep_669_tracing.py", line 517, in py_raise_callback
    or py_db.stop_on_failed_tests)
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'PyDB' object has no attribute 'stop_on_failed_tests'
Traceback (most recent call last):
  File "/usr/lib/python3.12/logging/config.py", line 581, in configure
    handler = self.configure_handler(handlers[name])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/logging/config.py", line 792, in configure_handler
    proxy_queue = MM().Queue()
                  ^^^^
  File "/usr/lib/python3.12/multiprocessing/context.py", line 57, in Manager
    m.start()
  File "/usr/lib/python3.12/multiprocessing/managers.py", line 566, in start
    self._address = reader.recv()
                    ^^^^^^^^^^^^^
  File "/usr/lib/python3.12/multiprocessing/connection.py", line 250, in recv
    buf = self._recv_bytes()
          ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/multiprocessing/connection.py", line 430, in _recv_bytes
    buf = self._recv(4)
          ^^^^^^^^^^^^^
  File "/usr/lib/python3.12/multiprocessing/connection.py", line 399, in _recv
    raise EOFError
EOFError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/opt/pycharm-2024.1.1/plugins/python/helpers/pydev/pydevd.py", line 2247, in <module>
    main()
  File "/opt/pycharm-2024.1.1/plugins/python/helpers/pydev/pydevd.py", line 2229, in main
    globals = debugger.run(setup['file'], None, None, is_module)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/pycharm-2024.1.1/plugins/python/helpers/pydev/pydevd.py", line 1539, in run
    return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/pycharm-2024.1.1/plugins/python/helpers/pydev/pydevd.py", line 1563, in _exec
    runpy._run_module_as_main(module_name, alter_argv=False)
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/*/.venv/lib/python3.12/site-packages/uvicorn/__main__.py", line 4, in <module>
    uvicorn.main()
  File "/home/*/.venv/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/*/.venv/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/*/.venv/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/*/.venv/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/*/.venv/lib/python3.12/site-packages/uvicorn/main.py", line 410, in main
    run(
  File "/home/*/.venv/lib/python3.12/site-packages/uvicorn/main.py", line 577, in run
    server.run()
  File "/home/*/.venv/lib/python3.12/site-packages/uvicorn/server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/pycharm-2024.1.1/plugins/python/helpers-pro/pydevd_asyncio/pydevd_nest_asyncio.py", line 138, in run
    return loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
  File "/home/*/.venv/lib/python3.12/site-packages/uvicorn/server.py", line 69, in serve
    await self._serve(sockets)
  File "/home/*/.venv/lib/python3.12/site-packages/uvicorn/server.py", line 76, in _serve
    config.load()
  File "/home/*/.venv/lib/python3.12/site-packages/uvicorn/config.py", line 434, in load
    self.loaded_app = import_from_string(self.app)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/*/.venv/lib/python3.12/site-packages/uvicorn/importer.py", line 19, in import_from_string
    module = importlib.import_module(module_str)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/*/app.py", line 14, in <module>
    app = Litestar([index, get_book])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/*/.venv/lib/python3.12/site-packages/litestar/app.py", line 487, in __init__
    self.get_logger = self.logging_config.configure()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/*/.venv/lib/python3.12/site-packages/litestar/logging/config.py", line 303, in configure
    config.dictConfig(values)
  File "/usr/lib/python3.12/logging/config.py", line 920, in dictConfig
    dictConfigClass(config).configure()
  File "/usr/lib/python3.12/logging/config.py", line 588, in configure
    raise ValueError('Unable to configure handler '
ValueError: Unable to configure handler 'queue_listener'
python-BaseException

Litestar Version

2.9.1

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Note

While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar
@Rey092 Rey092 added the Bug 🐛 This is something that is not working as expected label Jul 25, 2024
@Rey092 Rey092 changed the title Bug: Litestar Logging in Python3.12: Unable to configure handler 'queue_listener' (Debug-mode) Bug: Litestar Logging in Python3.12: Unable to configure handler 'queue_listener' (Pycharm Debugger) Jul 25, 2024
@provinzkraut
Copy link
Member

This is not a bug in Litestar, but in Python 3.12.4, which introduced breaking changes in the logging module with python/cpython#120030.

As a workaround you can stick to a Python version that doesn't have the bug (3.12.3 should work) and wait until 3.12.5 comes out with the fixes.

See also #3591.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 This is something that is not working as expected
Projects
None yet
Development

No branches or pull requests

2 participants