Pyhiveapi icon indicating copy to clipboard operation
Pyhiveapi copied to clipboard

[BUG] unasync'd HiveSession.updateData generates warnings and exceptions on lock acquisition / release

Open gormanb opened this issue 1 year ago • 2 comments

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 avatar Jan 14 '24 00:01 gormanb

@gormanb Yes please raise a pr for this

Khole-FG avatar Jan 14 '24 09:01 Khole-FG

@gormanb Yes please raise a pr for this

Done!

gormanb avatar Jan 14 '24 14:01 gormanb

Fixed by PR #75 in commit b3ee963.

gormanb avatar Jul 07 '24 16:07 gormanb