-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-5080 - Convert test.test_examples to async #2097
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 7 commits
a277e72
9706379
42bf75c
a131f48
19ce266
5a1f434
b293c94
524de44
9c26277
145e787
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 |
---|---|---|
|
@@ -381,14 +381,14 @@ def disable(self): | |
|
||
|
||
class ConcurrentRunner(PARENT): | ||
def __init__(self, name, *args, **kwargs): | ||
def __init__(self, **kwargs): | ||
if _IS_SYNC: | ||
super().__init__(*args, **kwargs) | ||
self.name = name | ||
super().__init__(**kwargs) | ||
self.name = kwargs.get("name", "ConcurrentRunner") | ||
self.stopped = False | ||
self.task = None | ||
if "target" in kwargs: | ||
self.target = kwargs["target"] | ||
self.target = kwargs.get("target", None) | ||
self.args = kwargs.get("args", []) | ||
|
||
if not _IS_SYNC: | ||
|
||
|
@@ -404,5 +404,8 @@ def is_alive(self): | |
|
||
async def run(self): | ||
if self.target: | ||
await self.target() | ||
if self.args: | ||
await self.target(*self.args) | ||
else: | ||
await self.target() | ||
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.
|
||
self.stopped = 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. Do we need to set stopped to try even when target raises? If so I suggest using try/finally. 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. Good point, I'd say so. |
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.
When would "target" ever be None?
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.
Good point, we'd want it to throw an error here instead of being a silent no-op.