-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
Worker processes #1781
Worker processes #1781
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1781 +/- ##
========================================
Coverage 99.64% 99.64%
========================================
Files 114 117 +3
Lines 14503 14759 +256
Branches 1105 1112 +7
========================================
+ Hits 14451 14707 +256
Misses 37 37
Partials 15 15
|
I would really appreciate some advice on how to make the segfault test not flaky! 😅 |
interesting PR! In our Trio experience, the use cases we've had for subprocess have been 1) some synchronous code like a heavy scipy call can't be divided, or otherwise we're playing games with "manual scheduling", i.e. I once did make a primitive subprocess for the app, simply using the |
Make a process cache with similar semantics to thread cache provide interface to submit sync functions to the process cache
It's not actually necessary, I was using it to confirm that the processes died as expected and should have removed it earlier.
also avoids extra thread per process on windows
e12e83d
to
9260def
Compare
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.
this would be great stuff
608a64a
to
e9bd34b
Compare
Closing in favor of trio-parallel. Feel free to reopen someday though! |
This PR provides the missing piece to close #5. This solution is based on
multiprocessing
and mimics the modern Trio thread cache. (You will recognize a lot of re-used code!)My motivation for writing this is that most of my projects end up cpu-bound. I iterated on a bunch of ways to interface with
multiprocessing
andconcurrent.futures
, and actually found some nearly trivial solutions that met my current needs. But, I could see some gaps that I thought really needed filling, and just couldn't let go. So, here we are!The workers have the following features "requested" in #5:
multiprocessing
)And some extras I feel are very important
If those are the good, then the bad and ugly are:
multiprocessing
asyncfreeze_support
, pickleable objects only)multiprocessing.Manager
In a sentence, the case for basing these workers on
multiprocessing
is that it keeps a lot of complexity outside of Trio while offering a set of quirks that users are likely already familiar with.From #5 I understand that enthusiasm for (1) including a
to_process.run_sync
API in Trio and (2) basing it onmultiprocessing
has dampened over the years, but I wanted to offer you the first bite at the apple (and use your CI!) before I go off and try to learn all the bits to make a trio-cookiecutter project work.TODO: