aiorwlock icon indicating copy to clipboard operation
aiorwlock copied to clipboard

Errors caused by no running event loop

Open Danyc0 opened this issue 2 years ago • 1 comments

I've been using the library for a while in various projects, and after recent python updates I'm now getting the same error in all of them: "env/lib/python3.10/site-packages/aiorwlock/__init__.py", line 242, in __init__ loop = asyncio.get_running_loop() RuntimeError: no running event loop

I tested it on the example in the README of this repo and it gives a deprecation warning of the same thing: python main.py main.py:19: DeprecationWarning: There is no current event loop

I'm using python v3.10.7, and aiorwlock v1.3.0 straight from pip

Thanks!

Danyc0 avatar Oct 14 '22 21:10 Danyc0

Simple solution is to use the objects only within code that is running inside a loop (as per the README).

Though I can see the asyncio primitives have implemented a lazy-load approach that avoids that catch. We could update the implementation to something like that. Let me know if you'd like to work on a PR to update it.

Dreamsorcerer avatar Oct 15 '22 00:10 Dreamsorcerer

I have opened a PR to fix this issue, but while it is not merged I have published rijenkii-aiorwlock from my pypi branch with that patch applied.

rijenkii avatar Dec 29 '23 09:12 rijenkii

Ah, seems I unsubscribed from PR notifications at some point...

Dreamsorcerer avatar Dec 29 '23 14:12 Dreamsorcerer

I tested it on the example in the README of this repo and it gives a deprecation warning of the same thing: python main.py main.py:19: DeprecationWarning: There is no current event loop

Also, this part is caused by using deprecated functions. We should create another PR to update all examples etc. to use asyncio.run().

Dreamsorcerer avatar Dec 29 '23 14:12 Dreamsorcerer