aio-libs/aiorwlock

Errors caused by no running event loop

Closed this issue · 4 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!

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.

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.

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

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().