Релиз
This commit is contained in:
+3
-14
@@ -54,19 +54,6 @@ async def ami_listening():
|
|||||||
conn_check_task = asyncio.create_task(check_connection())
|
conn_check_task = asyncio.create_task(check_connection())
|
||||||
conn_check_task.add_done_callback(lambda t: ami_listening() if t.result() else None)
|
conn_check_task.add_done_callback(lambda t: ami_listening() if t.result() else None)
|
||||||
|
|
||||||
# запуск check_pending ежедневно в 23:00
|
|
||||||
async def daily_check_pending():
|
|
||||||
while True:
|
|
||||||
now = datetime.now()
|
|
||||||
if now.hour == 23 and now.minute == 0 and now.second < 5:
|
|
||||||
logging.info("Checking pending calls...")
|
|
||||||
await callhandler.check_pending()
|
|
||||||
await asyncio.sleep(60)
|
|
||||||
else:
|
|
||||||
await asyncio.sleep(1)
|
|
||||||
|
|
||||||
daily_check_pending_task = asyncio.create_task(daily_check_pending())
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
@@ -96,10 +83,12 @@ async def ami_listening():
|
|||||||
await callhandler.handle_event(event)
|
await callhandler.handle_event(event)
|
||||||
if config.DEBUG:
|
if config.DEBUG:
|
||||||
await full_log(event)
|
await full_log(event)
|
||||||
|
if callhandler.date != datetime.now().date():
|
||||||
|
await callhandler.check_pending()
|
||||||
|
callhandler.check_date()
|
||||||
except (KeyboardInterrupt, SystemExit):
|
except (KeyboardInterrupt, SystemExit):
|
||||||
logging.info("Exiting...")
|
logging.info("Exiting...")
|
||||||
s.close()
|
s.close()
|
||||||
daily_check_pending_task.cancel()
|
|
||||||
except ConnectionResetError:
|
except ConnectionResetError:
|
||||||
logging.warning("Connection reset. Restarting...")
|
logging.warning("Connection reset. Restarting...")
|
||||||
await ami_listening()
|
await ami_listening()
|
||||||
|
|||||||
Reference in New Issue
Block a user