Skip to content

fix: add special handling for mellea global event loop when forked#624

Open
jakelorocco wants to merge 1 commit intomainfrom
jal/async-with-forks
Open

fix: add special handling for mellea global event loop when forked#624
jakelorocco wants to merge 1 commit intomainfrom
jal/async-with-forks

Conversation

@jakelorocco
Copy link
Contributor

@jakelorocco jakelorocco commented Mar 11, 2026

Misc PR

Type of PR

  • Bug Fix
  • New Feature
  • Documentation
  • Other

Description

  • Link to Issue: Fixes

Added special handling for Mellea's global event loop to handle cases where the process is forked. Added a test case for this scenario as well.

Testing

  • Tests added to the respective file if code was changed
  • New code has 100% coverage if code as added
  • Ensure existing tests and github automation passes (a maintainer will kick off the github automation when the rest of the PR is populated)

@github-actions
Copy link
Contributor

The PR description has been updated. Please fill out the template for your PR to be reviewed.

@mergify
Copy link

mergify bot commented Mar 11, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|release)(?:\(.+\))?:

@jakelorocco
Copy link
Contributor Author

jakelorocco commented Mar 11, 2026

Note: make sure tested on all backends. The new code path shouldn't trigger, but we should ensure that is the case. Done.

@jakelorocco jakelorocco force-pushed the jal/async-with-forks branch from 8a664ff to e940c95 Compare March 11, 2026 18:22
@jakelorocco jakelorocco force-pushed the jal/async-with-forks branch from e940c95 to cbd91e1 Compare March 11, 2026 19:25
@jakelorocco jakelorocco marked this pull request as ready for review March 11, 2026 19:42
@jakelorocco jakelorocco requested a review from a team as a code owner March 11, 2026 19:42
Copy link
Member

@psschwei psschwei left a comment

Choose a reason for hiding this comment

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

LGTM

ctx = multiprocessing.get_context("fork")

def child():
import mellea.helpers.event_loop_helper as elh
Copy link
Member

Choose a reason for hiding this comment

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

do we need to reimport ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably not but it ensures that the singleton patten works across forks.

@jakelorocco
Copy link
Contributor Author

Will wait for Zhang-Wei to confirm this fixes his issues with Agent Lightning before merging.

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