From 781051783cfe7ccd262ef605b54143510f1acaa5 Mon Sep 17 00:00:00 2001 From: Teknique Date: Mon, 24 Jul 2023 17:16:13 -0700 Subject: [PATCH] Responder tries to open the key before writing. --- veilid-python/chat.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/veilid-python/chat.py b/veilid-python/chat.py index 29328980..9dd599b0 100755 --- a/veilid-python/chat.py +++ b/veilid-python/chat.py @@ -62,11 +62,17 @@ async def start(): await rc.delete_dht_record(rec.key) -async def respond(key, writer): +async def respond(key): conn = await veilid.json_api_connect("localhost", 5959, cb) rc = await conn.new_routing_context() async with rc: + try: + await rc.open_dht_record(key, None) + except veilid.error.VeilidAPIErrorGeneric as exc: + if exc.message != 'record is already open and should be closed first': + raise + await chatter(rc, key, 1, 0) @@ -83,7 +89,7 @@ if __name__ == "__main__": if sys.argv[1] == "--start": func = start() elif sys.argv[1] == "--respond": - func = respond(sys.argv[2], sys.argv[3]) + func = respond(sys.argv[2]) elif sys.argv[1] == "--clean": func = clean(sys.argv[2]) else: