-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make AsyncioExecutor a shared resource across EngineClients #5976
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 4 commits
c46168a
d60f01c
29a25a9
0ca1298
caed447
d6ddf96
412a985
45c7d14
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 |
---|---|---|
|
@@ -86,6 +86,12 @@ def submit(self, func: Callable[..., Awaitable[_R]], *args, **kw) -> duet.Awaita | |
future = asyncio.run_coroutine_threadsafe(func(*args, **kw), self.loop) | ||
return duet.AwaitableFuture.wrap(future) | ||
|
||
_instance = None | ||
|
||
@classmethod | ||
def instance(cls): | ||
return AsyncioExecutor._instance if AsyncioExecutor._instance else cls() | ||
|
||
|
||
class EngineClient: | ||
"""Client for the Quantum Engine API handling protos and gRPC client. | ||
|
@@ -124,7 +130,7 @@ def __init__( | |
|
||
@cached_property | ||
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'd suggest removing this 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. Done 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. Oops, need to add back 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. Makes sense. Fixed and tested; thanks! |
||
def _executor(self) -> AsyncioExecutor: | ||
return AsyncioExecutor() | ||
return AsyncioExecutor.instance() | ||
wcourtney marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@cached_property | ||
def grpc_client(self) -> quantum.QuantumEngineServiceAsyncClient: | ||
|
Uh oh!
There was an error while loading. Please reload this page.