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

refactor: fix asyncio DeprecationWarnings #257

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

terop
Copy link
Contributor

@terop terop commented Nov 11, 2024

Calling get_event_loop() in Python 3.12 and newer when no event loop is running is deprecated. The recommended option is to use asyncio.run() instead.

Fixes #246.

@terop terop force-pushed the fix_asyncio_deprecationwarning_in_examples branch from 4b9e0c3 to 8736a7d Compare November 23, 2024 17:27
@terop terop changed the title docs: fix most asyncio DeprecationWarnings docs: fix asyncio DeprecationWarnings Nov 23, 2024
Copy link
Owner

@ttu ttu left a comment

Choose a reason for hiding this comment

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

Good fixes!

You could also change get_event_loop to get_running_loop:

loop = asyncio.get_event_loop()

I will make some more tests before merging this.

ruuvitag_sensor/__main__.py Show resolved Hide resolved
examples/rx_async.py Show resolved Hide resolved
@terop terop force-pushed the fix_asyncio_deprecationwarning_in_examples branch 2 times, most recently from a1a60db to 6e02ba9 Compare December 6, 2024 13:30
@terop terop changed the title docs: fix asyncio DeprecationWarnings refactor: fix asyncio DeprecationWarnings Dec 6, 2024
Copy link
Owner

@ttu ttu left a comment

Choose a reason for hiding this comment

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

There was a problem with Bleak adapter's asyncio.queue and compatibility with asyncio.run with Python 3.9 #186

We could just add comment to README and note to examples.

examples/get_async_bleak.py Show resolved Hide resolved
README.md Show resolved Hide resolved
Calling get_event_loop() in Python 3.12 and newer when no event loop
is running is deprecated. The recommended option is to use asyncio.run()
instead.
@terop terop force-pushed the fix_asyncio_deprecationwarning_in_examples branch from 6e02ba9 to bd3b952 Compare December 12, 2024 17:54
@ttu ttu merged commit 9a252db into ttu:master Dec 13, 2024
5 checks passed
@ttu
Copy link
Owner

ttu commented Dec 13, 2024

Thanks 🎉

@terop terop deleted the fix_asyncio_deprecationwarning_in_examples branch December 14, 2024 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecation warning in examples
2 participants