question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Difficulty in understanding Uvicorn logs

See original GitHub issue

I am facing an issue in Uvicorn where a background process is crashing the whole application intermittently. I want to understand the logs thrown by Uvicorn, as I am not able to reproduce this issue reliably.

Logs:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/uvicorn/server.py", line 184, in main_loop
    should_exit = await self.on_tick(counter)
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "runner.py", line 8, in <module>
    uvicorn.run(
  File "/usr/local/lib/python3.8/site-packages/uvicorn/main.py", line 386, in run
    server.run()
  File "/usr/local/lib/python3.8/site-packages/uvicorn/server.py", line 48, in run
    loop.run_until_complete(self.serve(sockets=sockets))
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.8/site-packages/uvicorn/server.py", line 68, in serve
    await self.main_loop()
RuntimeError: coroutine raised StopIteration

Environment

  • OS / Python / Uvicorn version: just run uvicorn --version: Running uvicorn 0.13.3 with CPython 3.8.5 on Linux
  • The exact command you’re running uvicorn with, all flags you passed included: Programatically running Uvicorn,
    uvicorn.run(
        app,
        host="0.0.0.0",
        port=4000,
        http="h11",
        # Maintaining logging at application instead of uvicorn
        access_log=False,
        log_config=None
    )

Additional context

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
gautamsinghania95commented, Feb 15, 2021

I am facing this issue in an enterprise code, and as I said before I was not able to reproduce this issue in an example. I was more looking into some insights of the logs, so I could understand the error better. See if you can help me out in this, like for example what is happening in the logs.

0reactions
gautamsinghania95commented, Feb 16, 2021

ok, let me see if i can provide more details or make this issue reproducible. closing this ticket for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Override Uvicorn Logger in FastAPI using Loguru
Generally it is very difficult to override default uvicorn logs. When one deploys an application using Uvicorn, this is how the default logs...
Read more >
FastAPI uvicorn not logging errors - Stack Overflow
I'm on it... I am currently tracing it back to the "uvicorn.error" logger which logs to stderr by default, but I got the...
Read more >
tiangolo/fastapi - Gitter
Something in your logging configuration is off. It looks to me like you have two handlers. One attached to the root logger and...
Read more >
How to Add Timestamp to FastAPI/Uvicorn Logs
... you will learn to configure Uvicorn and add timestamp to all the access and debug logs. Let's have a look at the...
Read more >
Settings - Uvicorn
Defaults to the $WEB_CONCURRENCY environment variable if available, or 1. Logging¶. --log-config <path> - Logging configuration file. Options: dictConfig() ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found