Pyhiveapi
Pyhiveapi copied to clipboard
[BUG] unasync'd HiveSession.updateData generates warnings and exceptions on lock acquisition / release
Describe the bug
When pyhiveapi
is packaged via unasync
, it removes the await
from this asyncio.Lock
acquisition in HiveSession.updateData
but otherwise leaves the asyncio.Lock
in place. As a result, calling updateData
generates the following warning:
/path/to/session.py:328: RuntimeWarning: coroutine 'Lock.acquire' was never awaited
self.updateLock.acquire()
... and can throw the following exception if it attempts to release the lock without having acquired it:
[1/13/2024, 2:20:09 PM] Error: Python exception: Lock is not acquired.
Expected behavior
Calling HiveSession.updateData
succeeds without spurious warning or errors.
Additional context
I have a patch here which simply adds an unasync
rule to convert the asyncio.Lock
in session.py
to threading.Lock
instead. No other code is affected by this change. I can open a PR, if you think this is an appropriate solution?
@gormanb Yes please raise a pr for this
@gormanb Yes please raise a pr for this
Done!
Fixed by PR #75 in commit b3ee963.