From 5e835c575eac97a5990dd67465044cef0f71602b Mon Sep 17 00:00:00 2001 From: "Baima (Hermes Agent)" Date: Fri, 8 May 2026 07:23:55 +0800 Subject: [PATCH] fix: ensure publisher cleanup on error in submit_document Resolves #871 The submit_document method creates a Publisher but doesn't wrap the start/send calls in try/finally. If pub.send() raises, pub.stop() is never called and the publisher leaks. This matches the existing pattern in emit_document_provenance (line 345) which already uses try/finally correctly. --- trustgraph-flow/trustgraph/librarian/service.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/trustgraph-flow/trustgraph/librarian/service.py b/trustgraph-flow/trustgraph/librarian/service.py index c24a5fe8..b41f177e 100755 --- a/trustgraph-flow/trustgraph/librarian/service.py +++ b/trustgraph-flow/trustgraph/librarian/service.py @@ -418,14 +418,15 @@ class Processor(AsyncProcessor): self.pubsub, q, schema=schema ) - await pub.start() + try: + await pub.start() - # FIXME: Time wait kludge? - await asyncio.sleep(1) + # FIXME: Time wait kludge? + await asyncio.sleep(1) - await pub.send(None, doc) - - await pub.stop() + await pub.send(None, doc) + finally: + await pub.stop() logger.debug("Document submitted")