Skip to content

Commit

Permalink
Fix subscriber close issue (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaranvpl authored Oct 10, 2024
1 parent 7a7e7a8 commit 0d8a0d1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fastagency/adapters/nats/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ async def start_chat() -> None: # type: ignore [return]
task = asyncio.create_task(start_chat()) # type: ignore
background_tasks.add(task)

def callback(t: asyncio.Task[Any]) -> None:
async def callback(t: asyncio.Task[Any]) -> None:
try:
background_tasks.discard(t)
syncify(subscriber.close)()
await subscriber.close()
except Exception as e:
logger.error(f"Error in callback: {e}")
logger.error(traceback.format_exc())

task.add_done_callback(callback)
task.add_done_callback(lambda t: asyncio.create_task(callback(t)))

except Exception as e:
await self._send_error_msg(e, logger)
Expand Down

0 comments on commit 0d8a0d1

Please sign in to comment.