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

Feat: Max requests flag to exit after N requests #405

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

alamorre
Copy link

@alamorre alamorre commented Feb 6, 2022

This is my first Open Source PR, but here is the --max-requests setting to periodically restart workers.

There are no tests, I'm happy to add them if this feature interests the Daphne maintainers.

Please let me know your thoughts!

Comment on lines +202 to +210
# Count completed requests and check against Max
self.server._complete_requests_counted += 1
if self.server._complete_requests_counted > self.server.max_requests:
logger.info('Max requests completed. Shutting down daphne...')
os.system("ps aux | grep 'daphne'")
bash_command = "kill $(ps aux | grep 'daphne' | awk '{print $2}')"
os.system(bash_command)
sys.exit(0)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. OK, so... the expectation would be that we restart after X requests, not just shut down right?

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

Successfully merging this pull request may close these issues.

2 participants