-
Notifications
You must be signed in to change notification settings - Fork 8
Fix H18 timeout by keeping event loop running after startup #408
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @pt2302, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request resolves a critical deployment issue on Heroku, specifically H18 timeout errors, by ensuring the application's asynchronous event loop remains active after its initial startup. The changes prevent the premature termination of the event loop, which was causing the Server Request Interrupted errors.
Highlights
- Event Loop Management: Modified the application's main entry point to explicitly keep the asyncio event loop running indefinitely after startup.
- Heroku H18 Timeout Fix: Addressed the Server Request Interrupted (H18) errors encountered on Heroku by preventing the event loop from terminating prematurely.
- Asynchronous Execution: Transitioned the main function to an async function and updated the application's execution to use asyncio.run().
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an H18 timeout issue on Heroku by preventing the event loop from terminating after bot startup. The change ensures the application continues running indefinitely to handle incoming requests.
- Replaced tornado's
run_syncwith native asyncio for event loop management - Added an infinite wait after startup to keep the event loop alive
- Removed tornado import as it's no longer needed
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| """main function for bot command""" | ||
| tornado.ioloop.IOLoop.current().run_sync(async_main) | ||
| await async_main() | ||
| await asyncio.Event().wait() |
Copilot
AI
Aug 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using asyncio.Event().wait() without ever setting the event creates an infinite wait that can only be interrupted by process termination. Consider using a more explicit approach like while True: await asyncio.sleep(3600) or creating a named event that can be set for graceful shutdown.
| await asyncio.Event().wait() | |
| while True: | |
| await asyncio.sleep(3600) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly addresses the H18 timeout issue on Heroku by ensuring the asyncio event loop remains active after the application starts. The change from a synchronous main function using tornado.ioloop to an asynchronous one using asyncio.Event().wait() is a clean and effective solution. The removal of the unused tornado import is also a good cleanup. The implementation is solid and I have no further suggestions.
jkachel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
What are the relevant tickets?
Follow-up to #407.
Description (What does it do?)
This PR fixes an issue with a
Server Request Interruptederror when deployed to Heroku, caused by the event loop terminating after Doof startup.How can this be tested?
Test by deploying to Heroku and making sure there are no H18 errors.