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

Asynchronous thread created by a worker was killed when the worker began restarting #3283

Open
skongkonga opened this issue Aug 23, 2024 · 0 comments

Comments

@skongkonga
Copy link

skongkonga commented Aug 23, 2024

Django: 4.2.5
Gunicorn: 22.0.0
Gevent: 24.2.1

In order to respond faster, I create an asynchronous thread (by "gevent.spawn" or "threading.Thread") to process the request after receiving it, and then respond directly. If the worker reaches the "max_requests" limit and starts to restart automatically, the asynchronous thread it created will also be forced to end (it is requesting other interfaces).

try:
    logger.debug('query started')
    response = requests.post(url, query)
    logger.debug('query done')
except:
    logger.debug('query failed')
finally:
    logger.debug('query finished')

When it happens, there is only 'query started' in the log, no 'query done' or even 'query finished'.

My temporary solution is to set "max_requests" to 0. But this doesn't completely solve the problem, because when I need to update the code I still need to restart the worker.

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

1 participant