Move AsyncioExecutor to separate file. - #6192
Merged
verult merged 6 commits intoJul 26, 2023
Merged
Conversation
verult
requested review from
a team,
cduck,
vtomole and
wcourtney
as code owners
July 10, 2023 21:45
maffoo
reviewed
Jul 11, 2023
| _instance = None | ||
|
|
||
| @classmethod | ||
| def instance(cls): |
Contributor
There was a problem hiding this comment.
nit: Add return type annotation. Also, I'd suggest adding a docstring indicating that this returns a single global AsyncioExecutor instance.
| while True: | ||
| await asyncio.sleep(1) | ||
|
|
||
| def submit(self, func: Callable[..., Awaitable[_R]], *args, **kw) -> duet.AwaitableFuture[_R]: |
Contributor
There was a problem hiding this comment.
We can make the types here more precise by using ParamSpec:
from typing_extensions import ParamSpec
...
P = ParamSpec("P")
...
def submit(self, func: Callable[P, Awaitable[R]], *args: P.args, **kwargs: P.kwargs) -> duet.AwaitableFuture[R]:
...| import duet | ||
|
|
||
|
|
||
| _R = TypeVar('_R') |
Contributor
There was a problem hiding this comment.
nit: I'd probably suggest using R here instead of _R, since it's more common. Not actually sure why we used underscore prefixes on type variables in engine_client.py.
| future = asyncio.run_coroutine_threadsafe(func(*args, **kw), self.loop) | ||
| return duet.AwaitableFuture.wrap(future) | ||
|
|
||
| _instance = None |
Contributor
There was a problem hiding this comment.
nit: Add type annotation on this class var too.
maffoo
approved these changes
Jul 12, 2023
| return duet.AwaitableFuture.wrap(future) | ||
|
|
||
| _instance = None | ||
| _instance: 'AsyncioExecutor' = None |
Contributor
There was a problem hiding this comment.
nit: should be Optional['AsyncioExecutor']
verult
enabled auto-merge (squash)
July 26, 2023 18:18
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In preparation for the streaming client prototyped in #6145, AsyncioExecutor is pulled into a separate file so that it's accessible from
stream_manager.py, a dedicated file forStreamManager.@maffoo @wcourtney