Improved async context

This commit is contained in:
Profitroll 2023-03-22 10:33:21 +01:00
parent f82c7b309f
commit 4422a13ba9

View File

@ -116,10 +116,11 @@ if configGet("post", "mode"):
# uvloop.install()
# asyncio.run(main())
if __name__ == "__main__":
async def main():
logWrite(locale("startup", "console").format(str(pid)))
app.start()
await app.start()
if configGet("startup", "reports"):
try:
@ -133,7 +134,7 @@ if __name__ == "__main__":
),
)
if downtime.days >= 1:
app.send_message(
await app.send_message(
configGet("owner"),
locale(
"startup_downtime_days",
@ -141,7 +142,7 @@ if __name__ == "__main__":
).format(pid, downtime.days),
)
elif downtime.hours >= 1:
app.send_message(
await app.send_message(
configGet("owner"),
locale(
"startup_downtime_hours",
@ -149,7 +150,7 @@ if __name__ == "__main__":
).format(pid, downtime.hours),
)
else:
app.send_message(
await app.send_message(
configGet("owner"),
locale(
"startup_downtime_minutes",
@ -158,7 +159,7 @@ if __name__ == "__main__":
).format(pid, downtime.minutes),
)
else:
app.send_message(
await app.send_message(
configGet("owner"),
locale("startup", "message").format(pid),
)
@ -175,10 +176,10 @@ if __name__ == "__main__":
# if len(get(f'{configGet("address", "posting", "api")}/albums?q={configGet("queue", "posting", "api", "albums")}', headers={"Authorization": f"Bearer {token}"}).json()["results"]) == 0:
# post(f'{configGet("address", "posting", "api")}/albums?name={configGet("queue", "posting", "api", "albums")}&title={configGet("queue", "posting", "api", "albums")}', headers={"Authorization": f"Bearer {token}"})
idle()
await idle()
try:
app.send_message(
await app.send_message(
configGet("owner"),
locale("shutdown", "message").format(pid),
)
@ -197,4 +198,7 @@ if __name__ == "__main__":
scheduler.shutdown()
killProc(pid)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())