Skip to content

Conversation

@pt2302
Copy link
Contributor

@pt2302 pt2302 commented Aug 29, 2025

What are the relevant tickets?

Follow-up to #407.

Description (What does it do?)

This PR fixes an issue with a Server Request Interrupted error 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.

@pt2302 pt2302 requested a review from Copilot August 29, 2025 20:00
Copy link

@gemini-code-assist gemini-code-assist bot left a 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

  1. 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.

Copy link

Copilot AI left a 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_sync with 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()
Copy link

Copilot AI Aug 29, 2025

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.

Suggested change
await asyncio.Event().wait()
while True:
await asyncio.sleep(3600)

Copilot uses AI. Check for mistakes.
Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

Copy link
Contributor

@jkachel jkachel left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@pt2302 pt2302 merged commit 10f016c into master Sep 2, 2025
5 checks passed
@pt2302 pt2302 deleted the pt/keep_bot_running branch September 2, 2025 13:34
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.

3 participants