From f9d6606423e0a5559d262ce25700f7b9a1c410a1 Mon Sep 17 00:00:00 2001 From: gittihub-jpg Date: Fri, 8 May 2026 20:22:48 +0200 Subject: [PATCH] Fix publisher resource leak in librarian submit_document (#883) Wrap pub.start()/pub.send() in try/finally to guarantee pub.stop() is called on error. Remove unnecessary asyncio.sleep(1) kludge. --- trustgraph-flow/trustgraph/librarian/service.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/trustgraph-flow/trustgraph/librarian/service.py b/trustgraph-flow/trustgraph/librarian/service.py index c24a5fe8..0ab04ec4 100755 --- a/trustgraph-flow/trustgraph/librarian/service.py +++ b/trustgraph-flow/trustgraph/librarian/service.py @@ -418,14 +418,11 @@ class Processor(AsyncProcessor): self.pubsub, q, schema=schema ) - await pub.start() - - # FIXME: Time wait kludge? - await asyncio.sleep(1) - - await pub.send(None, doc) - - await pub.stop() + try: + await pub.start() + await pub.send(None, doc) + finally: + await pub.stop() logger.debug("Document submitted")