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

Remove global util.main_event_loop #2

Open
gnzsnz opened this issue Aug 15, 2024 · 2 comments
Open

Remove global util.main_event_loop #2

gnzsnz opened this issue Aug 15, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@gnzsnz
Copy link
Collaborator

gnzsnz commented Aug 15, 2024

from discussion #62 on ib_async

pull request #1 created

@gnzsnz gnzsnz added the bug Something isn't working label Aug 15, 2024
@gnzsnz
Copy link
Collaborator Author

gnzsnz commented Aug 18, 2024

deprecation warning on test results

======================= warnings summary =========================
tests/create_test.py:9
  /Users/gonzo/Documents/dev/eventkit/tests/create_test.py:9: DeprecationWarning: There is no current event loop
    loop = asyncio.get_event_loop_policy().get_event_loop()

proposed solution

try:
  loop = asyncio.get_running_loop()
except RuntimeError:
  loop = asyncio.new_event_loop()
  asyncio.set_event_loop(loop)

proposed solution to be applied to util.get_event_loopand tests/create_test.py

reference -> https://docs.python.org/3/library/asyncio-policy.html#asyncio.DefaultEventLoopPolicy

@mattsta
Copy link
Contributor

mattsta commented Aug 18, 2024

another good catch there.

I tried it in a couple places, and found even after that is fixed in the 3 tests using .get_event_loop(), then the underlying util.get_event_loop() starts failing again... but that got fixed by just adding this fix there too and also caching the first creation result and never creating another one.

After those updates, the tests work on 3.10 and 3.12 for me locally.

I'm adding/updating a next branch with those changes (and some other minor things). I'll add a PR against it, so see if those look right and we can merge more updates into a new version.

mattsta added a commit that referenced this issue Aug 18, 2024
Primarily due to version changes over time, this all used to work in
older versions, but Python 3.12 started issuing new warnings and errors
unless manual steps are used for event loop handling instead of automatic steps.

Fixes #2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants