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

Getting error while trying to log "WatchtowerWarning: Received message after logging system shutdown" #171

Open
dhiyan-nirva-ai opened this issue Feb 23, 2022 · 6 comments

Comments

@dhiyan-nirva-ai
Copy link

"watchtower_init_.py:381: WatchtowerWarning: Received message after logging system shutdown
warnings.warn("Received message after logging system shutdown", WatchtowerWarning)"

Getting the above error while logging ,

@EddyIonescu
Copy link

EddyIonescu commented Jun 19, 2022

Ran into this too, supplying use_queues=False to the CloudWatchLogHandler constructor function seemed to fix it. Might not be closing properly whenever you stop/start the server (like Django or Flask) you're using: #38

@ymguerra
Copy link

Hi, I am also having this issue, in my case I use Django + gunicorn (gevent), if I set use_queues=False it works. I think is somehow related to Gunicorn + gevent because we share the same configuration with others servers (celery and websocket) and all the logs are send from those servers but not from our Web server, any idea?

@o-nikolas
Copy link
Contributor

I think is somehow related to Gunicorn + gevent

Linking #89 for context

@Insighttful
Copy link

Hitting this issue using Uvicorn 0.24 and Fastapi 0.105.

@medley56
Copy link

I think I've fixed this issue by flushing all CloudWatchLogHandlers before exiting any process. I'm guessing the issue is that the logging system shuts down without waiting for the cloudwatch logs to finish transmitting.

The following code doesn't work if you have handlers attached to child loggers. This only flushes the handlers attached to the root logger.

def flush_cloudwatch_logs():
    """Force flush of all cloudwatch logging handlers. For example at the end of a process just before it is killed.

    Returns
    -------
    None
    """
    root_logger = logging.getLogger()
    for handler in root_logger.handlers:
        if isinstance(handler, watchtower.CloudWatchLogHandler):
            handler.flush()

@pascencio
Copy link

pascencio commented Aug 10, 2024

I have the same issue with uvicorn=0.30.5, fastapi[standard]=0.112.0 and watchtower=3.2.0. Disabling the queue option works fine but is too slow.

Please help!!

I will tray to fork and create a pull request if catch the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants