-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix: Update async utils to remove upcoming deprecated call #6297
Conversation
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
async def _run_given_tasks_async(tasks, event_loop=asyncio.get_event_loop(), executor=None): | ||
async def _run_given_tasks_async( | ||
tasks: List[Callable], event_loop: AbstractEventLoop, executor: Optional[ThreadPoolExecutor] = 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.
Did we use the default value at all?
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.
No, since the creation of this util the event loop was always specified and the helper methods are only called within this file:
aws-sam-cli/samcli/lib/utils/async_utils.py
Lines 127 to 131 in bbaefff
event_loop = asyncio.new_event_loop() | |
if not default_executor: | |
with ThreadPoolExecutor() as self.executor: | |
return run_given_tasks_async(self._async_tasks, event_loop, self.executor) | |
return run_given_tasks_async(self._async_tasks, event_loop) |
@@ -111,7 +116,7 @@ def add_async_task(self, function, *args): | |||
""" | |||
self._async_tasks.append(partial(function, *args)) | |||
|
|||
def run_async(self, default_executor=True): | |||
def run_async(self, default_executor: bool = True) -> list: |
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.
Thanks for adding type definitions!
Which issue(s) does this change fix?
None.
Why is this change necessary?
asyncio.get_event_loop()
is being deprecated in the future. Deprecation warns are starting to appear, which will cause tests to fail since warnings are treated as errors.How does it address the issue?
Removes the call to
asyncio.get_event_loop()
as a default value for the tasks.What side effects does this change have?
None.
Mandatory Checklist
PRs will only be reviewed after checklist is complete
make pr
passesmake update-reproducible-reqs
if dependencies were changedBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.