-
Notifications
You must be signed in to change notification settings - Fork 67
Zombie Process Fix #34
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
Changes from 2 commits
b3a9169
fb2285a
ca653f1
f502655
a92f697
0367a7d
4d78e3c
2be7ee2
e91436b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,8 @@ | |
|
|
||
| import asyncio | ||
|
|
||
| from typing import Coroutine | ||
|
|
||
|
|
||
| def run_sync(coro): | ||
| """Runs a coroutine and blocks until it has executed. | ||
|
|
@@ -45,3 +47,17 @@ def wrapped(self, *args, **kwargs): | |
| return result | ||
| wrapped.__doc__ = coro.__doc__ | ||
| return wrapped | ||
|
|
||
|
|
||
| async def await_or_block(func, *args, **kwargs): | ||
| """Awaits the function if it's an asynchronous function. Otherwise block | ||
| on execution. | ||
| """ | ||
| if asyncio.iscoroutinefunction(func): | ||
| return await func(*args, **kwargs) | ||
| else: | ||
| result = func(*args, **kwargs) | ||
| # Mocks mask that the function is a coroutine :/ | ||
| if isinstance(result, Coroutine): | ||
| return await result | ||
| return result | ||
|
Member
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. In jupyter_server, we will have something similar that we call ensure_async. We use it as a wrapper on a function call when we don't know if this function is async or not. I prefer that over passing the function object and its parameters to
Contributor
Author
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. I'm ok with that change, thanks for helping |
||
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.
Should it be
_async_wait_for_replyfor name consistency with_wait_for_reply?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.
I was thinking of exposing
async_wait_for_replyas not private so it could be used in contracts for extensibility since papermill ended up needing the blocking verison to extend behavior. If I'm doing that I should probably commit and makewait_for_reply, or revert the decision overall and keep with_async_wait_for_reply.