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