-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-4864 - Create async version of SpecRunnerThread #2094
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
Conversation
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.
not loving the duplicated code between sync and async but i'm guessing its because the async version needs some more methods? If so, then i understand and can live with it >.<
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.
The async version doesn't implement threading.Thread
, but it still needs to match the same API as the synchronous version. Let me see if I can reduce some of the duplication though.
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.
Did some refactoring, much less duplication now. Great call-out!
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.
awesome work!
if _IS_SYNC: | ||
await self.cond.wait(10) # type: ignore[call-arg] | ||
else: | ||
await asyncio.wait_for(self.cond.wait(), timeout=10) # type: ignore[arg-type] |
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.
Let's use our _async_cond_wait
compat function here to avoid the branching.
"""Run the 'runOnThread' operation.""" | ||
thread = self.entity_map[spec["thread"]] | ||
thread.schedule(lambda: self.run_entity_operation(spec["operation"])) | ||
await thread.schedule(functools.partial(self.run_entity_operation, spec["operation"])) |
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.
Are we running any async unified tests that use runOnThread?
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.
The SDAM unified tests are the only ones that use runOnThread
. Those are currently slated to be converted to async, yes.
def __init__(self, name): | ||
super().__init__() | ||
|
||
class ConcurrentRunner(PARENT): |
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.
Let's move this to utils.py since it will be used by non-spec tests.
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.
Since utils.py is not currently synchro'd, let's delay that move to PYTHON-5113, it'll involve a lot of git changes.
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.
Okay then what about helpers.py?
self.name = name | ||
self.stopped = False |
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.
Stopped is never set to True by this class.
No description provided.