diff --git a/src/neo4j/_async/_debug/_concurrency_check.py b/src/neo4j/_async/_debug/_concurrency_check.py index 47888492..afb54a4f 100644 --- a/src/neo4j/_async/_debug/_concurrency_check.py +++ b/src/neo4j/_async/_debug/_concurrency_check.py @@ -131,6 +131,8 @@ async def inner(*args, **kwargs): if acquired: try: item = await iter_.__anext__() + except StopAsyncIteration: + return finally: async with self.__tracebacks_lock: self.__tracebacks.pop() diff --git a/src/neo4j/_sync/_debug/_concurrency_check.py b/src/neo4j/_sync/_debug/_concurrency_check.py index 6a5ef9b3..e5da4f25 100644 --- a/src/neo4j/_sync/_debug/_concurrency_check.py +++ b/src/neo4j/_sync/_debug/_concurrency_check.py @@ -131,6 +131,8 @@ def inner(*args, **kwargs): if acquired: try: item = iter_.__next__() + except StopIteration: + return finally: with self.__tracebacks_lock: self.__tracebacks.pop()