Improved async context
This commit is contained in:
parent
f82c7b309f
commit
4422a13ba9
22
poster.py
22
poster.py
@ -116,10 +116,11 @@ if configGet("post", "mode"):
|
|||||||
# uvloop.install()
|
# uvloop.install()
|
||||||
# asyncio.run(main())
|
# asyncio.run(main())
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
async def main():
|
||||||
logWrite(locale("startup", "console").format(str(pid)))
|
logWrite(locale("startup", "console").format(str(pid)))
|
||||||
|
|
||||||
app.start()
|
await app.start()
|
||||||
|
|
||||||
if configGet("startup", "reports"):
|
if configGet("startup", "reports"):
|
||||||
try:
|
try:
|
||||||
@ -133,7 +134,7 @@ if __name__ == "__main__":
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
if downtime.days >= 1:
|
if downtime.days >= 1:
|
||||||
app.send_message(
|
await app.send_message(
|
||||||
configGet("owner"),
|
configGet("owner"),
|
||||||
locale(
|
locale(
|
||||||
"startup_downtime_days",
|
"startup_downtime_days",
|
||||||
@ -141,7 +142,7 @@ if __name__ == "__main__":
|
|||||||
).format(pid, downtime.days),
|
).format(pid, downtime.days),
|
||||||
)
|
)
|
||||||
elif downtime.hours >= 1:
|
elif downtime.hours >= 1:
|
||||||
app.send_message(
|
await app.send_message(
|
||||||
configGet("owner"),
|
configGet("owner"),
|
||||||
locale(
|
locale(
|
||||||
"startup_downtime_hours",
|
"startup_downtime_hours",
|
||||||
@ -149,7 +150,7 @@ if __name__ == "__main__":
|
|||||||
).format(pid, downtime.hours),
|
).format(pid, downtime.hours),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
app.send_message(
|
await app.send_message(
|
||||||
configGet("owner"),
|
configGet("owner"),
|
||||||
locale(
|
locale(
|
||||||
"startup_downtime_minutes",
|
"startup_downtime_minutes",
|
||||||
@ -158,7 +159,7 @@ if __name__ == "__main__":
|
|||||||
).format(pid, downtime.minutes),
|
).format(pid, downtime.minutes),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
app.send_message(
|
await app.send_message(
|
||||||
configGet("owner"),
|
configGet("owner"),
|
||||||
locale("startup", "message").format(pid),
|
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:
|
# 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}"})
|
# 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:
|
try:
|
||||||
app.send_message(
|
await app.send_message(
|
||||||
configGet("owner"),
|
configGet("owner"),
|
||||||
locale("shutdown", "message").format(pid),
|
locale("shutdown", "message").format(pid),
|
||||||
)
|
)
|
||||||
@ -197,4 +198,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
scheduler.shutdown()
|
scheduler.shutdown()
|
||||||
|
|
||||||
killProc(pid)
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
loop.run_until_complete(main())
|
||||||
|
Reference in New Issue
Block a user