try not to break
This commit is contained in:
parent
e3efdad3de
commit
810044e134
1 changed files with 16 additions and 10 deletions
|
@ -27,10 +27,12 @@ async def matrixmain(matrix_client: matrix.MatrixClient, mq_client: mq.MQClient,
|
|||
|
||||
client.add_event_callback(callback, RoomMessageText)
|
||||
|
||||
while True:
|
||||
try:
|
||||
await client.sync_forever(timeout=30000, full_state=True) # milliseconds
|
||||
log.info('exiting from the matrix loop')
|
||||
client.logout()
|
||||
break
|
||||
except Exception as e:
|
||||
log.error(f'exception in matrix loop: {e}')
|
||||
|
||||
|
@ -40,10 +42,14 @@ async def mqmain(rabbit_client: mq.MQClient, matrix_client: matrix.MatrixClient)
|
|||
async with rabbit_client.queue.iterator() as queue_iter:
|
||||
async for message in queue_iter:
|
||||
async with message.process():
|
||||
try:
|
||||
body = message.body.decode()
|
||||
br = protocol.json_to_bot_response(body)
|
||||
# logging.info(f'New message from MQ: {str(br)[:24]}...')
|
||||
await matrix.send_text(matrix_client, br)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
log.error(f'exception in mq loop: {e}')
|
||||
|
||||
try:
|
||||
async with rabbit_client.connection:
|
||||
|
|
Loading…
Reference in a new issue