-
Notifications
You must be signed in to change notification settings - Fork 12
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
We aint got zombie shields #188
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5ed5d18
Begin rpc_module_paths deprecation
goodboy 3df001f
Fix msg pub global lock sharing
goodboy e546ead
Pub sub internals type fixes
goodboy 14d6014
Add an example which breaks shielded proc waits
goodboy 9f4e497
Don't shield proc waits
goodboy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import trio | ||
import tractor | ||
|
||
|
||
log = tractor.log.get_logger('multiportal') | ||
|
||
|
||
async def stream_data(seed=10): | ||
log.info("Starting stream task") | ||
|
||
for i in range(seed): | ||
yield i | ||
await trio.sleep(0) # trigger scheduler | ||
|
||
|
||
async def stream_from_portal(p, consumed): | ||
|
||
async for item in await p.run(stream_data): | ||
if item in consumed: | ||
consumed.remove(item) | ||
else: | ||
consumed.append(item) | ||
|
||
|
||
async def main(): | ||
|
||
async with tractor.open_nursery(loglevel='info') as an: | ||
|
||
p = await an.start_actor('stream_boi', enable_modules=[__name__]) | ||
|
||
consumed = [] | ||
|
||
async with trio.open_nursery() as n: | ||
for i in range(2): | ||
n.start_soon(stream_from_portal, p, consumed) | ||
|
||
# both streaming consumer tasks have completed and so we should | ||
# have nothing in our list thanks to single threadedness | ||
assert not consumed | ||
|
||
await an.cancel() | ||
|
||
|
||
if __name__ == '__main__': | ||
trio.run(main) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,7 +247,7 @@ async def new_proc( | |
# send additional init params | ||
await chan.send({ | ||
"_parent_main_data": subactor._parent_main_data, | ||
"rpc_module_paths": subactor.rpc_module_paths, | ||
"enable_modules": subactor.enable_modules, | ||
"_arb_addr": subactor._arb_addr, | ||
"bind_host": bind_addr[0], | ||
"bind_port": bind_addr[1], | ||
|
@@ -273,10 +273,14 @@ async def new_proc( | |
# ``trio.Process.__aexit__()`` (it tears down stdio | ||
# which will kill any waiting remote pdb trace). | ||
|
||
# TODO: No idea how we can enforce zombie | ||
# reaping more stringently without the shield | ||
# we used to have below... | ||
|
||
# always "hard" join sub procs: | ||
# no actor zombies allowed | ||
with trio.CancelScope(shield=True): | ||
await proc.wait() | ||
# with trio.CancelScope(shield=True): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main change. Thoughts on this very welcome. |
||
await proc.wait() | ||
else: | ||
# `multiprocessing` | ||
assert _ctx | ||
|
@@ -290,7 +294,7 @@ async def new_proc( | |
# if we're the "main" process start the forkserver | ||
# only once and pass its ipc info to downstream | ||
# children | ||
# forkserver.set_forkserver_preload(rpc_module_paths) | ||
# forkserver.set_forkserver_preload(enable_modules) | ||
forkserver.ensure_running() | ||
fs_info = ( | ||
fs._forkserver_address, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is just an example that shows the hang in practice.
The problem is if we have a nursery exit before receiving a ctr-c we'll be stuck in the shielded
proc.wait()
and have no way for the user to trigger graceful exit...