Skip to content
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

exporter/coordinator/client: create/set event loop explicitly #1059

Conversation

Bastian-Krause
Copy link
Member

Description
Calling asyncio.get_event_loop() with no current event loop is deprecated since Python 3.10 and will be an error in Python >=3.12, see docs.

So create a new event loop explicitly and set it as the current event loop for the current OS thread.

Checklist

  • PR has been tested

Fixes #1056

Calling asyncio.get_event_loop() with no current event loop is
deprecated since Python 3.10 and will be an error in Python >=3.12.

So create a new event loop explicitly and set it as the current event
loop for the current OS thread.

Signed-off-by: Bastian Krause <[email protected]>
Calling asyncio.get_event_loop() with no current event loop is
deprecated since Python 3.10 and will be an error in Python >=3.12.

So create a new event loop explicitly and set it as the current event
loop for the current OS thread.

Signed-off-by: Bastian Krause <[email protected]>
Calling asyncio.get_event_loop() with no current event loop is
deprecated since Python 3.10 and will be an error in Python >=3.12.

So create a new event loop explicitly and set it as the current event
loop for the current OS thread.

Signed-off-by: Bastian Krause <[email protected]>
@codecov
Copy link

codecov bot commented Jan 9, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.3%. Comparing base (5dc31f5) to head (0a81011).
Report is 715 commits behind head on master.

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #1059   +/-   ##
======================================
  Coverage    63.3%   63.3%           
======================================
  Files         152     152           
  Lines       11311   11313    +2     
======================================
+ Hits         7170    7172    +2     
  Misses       4141    4141           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -1235,7 +1233,10 @@ async def export(self, place, target):
def start_session(url, realm, extra):
from autobahn.asyncio.wamp import ApplicationRunner

loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this break use-cases where the caller already has a running event loop?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the case in our codebase. But it could be the case in third-party code, though. So maybe add a loop kwarg and use that if it's specified?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some context for the Python upstream change: python/cpython#83710

@kjeldflarup
Copy link
Contributor

I just tried to include this in the build of my test runner container.

git clone -b bst/explicit-event-loop https://github.com/Bastian-Krause/labgrid.git /opt/labgrid

I however still gets this warning:

tests_self/test__ssh.py::test_ssh
  /usr/local/lib/python3.10/dist-packages/autobahn/asyncio/websocket.py:300: DeprecationWarning: There is no current event loop
    self.loop = loop or asyncio.get_event_loop()

Do I need to do more than updating my test runner?

@Bastian-Krause
Copy link
Member Author

This PR needs more work. We need to understand the reasoning behind this deprecation better and then update this PR with a solution covering all use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DeprecationWarning: There is no current event loop
3 participants