Skip to content

Use Python spawned threads for worker event loop creation #626

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

Closed

Conversation

benjipelletier
Copy link
Contributor

Summary:
Seeing the following error when running paft at large scale:

Fatal Python error: PyGILState_Release: thread state 0x7f7271468000 must be current when releasing

Seems to be an issue with interpreter shutdown due to the main thread (actor_paft.py) ending before messages are done being handled in background actors. The interpreter begins shutdown because it is not aware of our raw rust thread created to host py actor event loops.

  • Make the thread needed to handle py actors a Python Thread
  • Create the asyncio runtime for py actors in python as well
  • Grab the asyncio runtime to use for task locals through a global

Reviewed By: dulinriley

Differential Revision: D78745022

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 23, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78745022

benjipelletier added a commit to benjipelletier/monarch-1 that referenced this pull request Jul 24, 2025
…bs#626)

Summary:

Seeing the following error when running paft at large scale:
```
Fatal Python error: PyGILState_Release: thread state 0x7f7271468000 must be current when releasing
```
Seems to be an issue with interpreter shutdown due to the main thread (actor_paft.py) ending before messages are done being handled in background actors. The interpreter begins shutdown because it is not aware of our raw rust thread created to host py actor event loops.

* Make the thread needed to handle py actors a Python Thread
* Create the asyncio runtime for py actors in python as well
* Grab the asyncio runtime to use for task locals through a global

Reviewed By: dulinriley

Differential Revision: D78745022
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78745022

benjipelletier added a commit to benjipelletier/monarch-1 that referenced this pull request Jul 24, 2025
…bs#626)

Summary:

Seeing the following error when running paft at large scale:
```
Fatal Python error: PyGILState_Release: thread state 0x7f7271468000 must be current when releasing
```
Seems to be an issue with interpreter shutdown due to the main thread (actor_paft.py) ending before messages are done being handled in background actors. The interpreter begins shutdown because it is not aware of our raw rust thread created to host py actor event loops.

* Make the thread needed to handle py actors a Python Thread
* Create the asyncio runtime for py actors in python as well
* Grab the asyncio runtime to use for task locals through a global

Reviewed By: dulinriley

Differential Revision: D78745022
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78745022

…bs#626)

Summary:

Seeing the following error when running paft at large scale:
```
Fatal Python error: PyGILState_Release: thread state 0x7f7271468000 must be current when releasing
```
Seems to be an issue with interpreter shutdown due to the main thread (actor_paft.py) ending before messages are done being handled in background actors. The interpreter begins shutdown because it is not aware of our raw rust thread created to host py actor event loops.

* Make the thread needed to handle py actors a Python Thread
* Create the asyncio runtime for py actors in python as well
* Grab the asyncio runtime to use for task locals through a global

Reviewed By: dulinriley

Differential Revision: D78745022
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78745022

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 973411e.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants