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

Sanic hangs for around 20 seconds after every 3 minutes #2883

Open
1 task
sham-hq opened this issue Dec 22, 2023 · 4 comments
Open
1 task

Sanic hangs for around 20 seconds after every 3 minutes #2883

sham-hq opened this issue Dec 22, 2023 · 4 comments

Comments

@sham-hq
Copy link

sham-hq commented Dec 22, 2023

Link to code

No response

Proposal

I am using Sanic version 21.12.1 on Ubuntu 20.04.5 and below is my code to start the sanic server:

def init():
    sanic_app.run(host=HOST, port=PORT, debug=DEBUG, workers=2, access_log=False)

The issue I am facing is, after every 3 minutes, server hangs for 20 seconds and then after 20 seconds starts responding. So I started sanic with Debug True, and what I found is, before printing below line, server hangs for 20 secs, and after below line appears in log, sanic resumes responding:
Executing <Task pending name='Task-36' coro=<SignalRouter._dispatch() running at /home/ubuntu/.local/lib/python3.8/site-packages/sanic/signals.py:161> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f5d2c2e0d60>()] created at /usr/lib/python3.8/asyncio/tasks.py:654> created at /home/ubuntu/.local/lib/python3.8/site-packages/sanic/signals.py:193> took 20.112 seconds
This is happening after every around 3 mins.
Can anybody please guide me what is this and how to solve/handle it?
Thanks

Additional context

No response

Is this a breaking change?

  • Yes
@sjsadowski
Copy link
Contributor

Please provide a link to your code so that we can review.

@sham-hq
Copy link
Author

sham-hq commented Dec 23, 2023

The code is in private repository, sorry can't share the link of the same. Or if you can share what specific part of code/configuration you want to see, will try to share that separately.
But I believe some background task is causing this.
And I am not being able to find out that task by Task-id Task-36.
So, if you can help me to locate same.
Thanks

@sjsadowski
Copy link
Contributor

Or if you can share what specific part of code/configuration you want to see, will try to share that separately.

Since we don't know your code, we can't really tell you what we'd want to see. What I can tell you is that whatever that code is likely has some blocking calls in it due to the fact that it's taking so long (~ 20 seconds) but as a background task, it should not be impacting the rest of your application.

I am guessing this is something you took over, not wrote yourself?

@iAndriy
Copy link
Contributor

iAndriy commented Dec 24, 2023

The code is in private repository, sorry can't share the link of the same. Or if you can share what specific part of code/configuration you want to see, will try to share that separately. But I believe some background task is causing this. And I am not being able to find out that task by Task-id Task-36. So, if you can help me to locate same. Thanks

@sham-hq Would be happy to help you, though if I've got it right you cannot share code "as is". I am seconding @sjsadowski comment on the blocking call which takes too long. Have you tried to play with number of workers ?
If you can get back with reproducible example we can figure things out.
Checkout this guide from StackOverflow for details on how to do so.

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

No branches or pull requests

3 participants