fix: ensure publisher is cleaned up on error in submit_document

If pub.send() raises an exception, pub.stop() was never called,
leaking the publisher and its underlying connection.

Wrap the pub.start()/pub.send() calls in try/finally so pub.stop()
is always called, matching the existing pattern at lines 345-361.

Fixes #871
This commit is contained in:
forhim007 2026-05-07 23:24:11 +08:00
parent 1ffae12559
commit ec56f69158

View file

@ -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")