diff --git a/src/neo4j/_async/_debug/_concurrency_check.py b/src/neo4j/_async/_debug/_concurrency_check.py index 478884921..afb54a4f2 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 6a5ef9b3c..e5da4f252 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()