Fix startup scheduling thing
This commit is contained in:
parent
3e1c780169
commit
70184112c1
2 changed files with 27 additions and 24 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
import datetime
|
import datetime
|
||||||
|
import asyncio
|
||||||
|
|
||||||
from util import make_session
|
from util import make_session
|
||||||
from generate import generate_order, generate_punishment
|
from generate import generate_order, generate_punishment
|
||||||
|
|
@ -133,7 +134,9 @@ async def punishment_issue(session, outstanding_order):
|
||||||
punishment_str
|
punishment_str
|
||||||
)
|
)
|
||||||
|
|
||||||
|
order_check_lock = asyncio.Lock()
|
||||||
async def order_check():
|
async def order_check():
|
||||||
|
async with order_check_lock:
|
||||||
async with make_session() as session:
|
async with make_session() as session:
|
||||||
outstanding_orders = order_status_outstanding()
|
outstanding_orders = order_status_outstanding()
|
||||||
for outstanding_order in outstanding_orders:
|
for outstanding_order in outstanding_orders:
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class OrderScheduler():
|
||||||
outstanding_orders = order_status_outstanding()
|
outstanding_orders = order_status_outstanding()
|
||||||
for oo in outstanding_orders:
|
for oo in outstanding_orders:
|
||||||
self.scheduler.once(
|
self.scheduler.once(
|
||||||
datetime.datetime.fromisoformat(oo['due_at']) + GRACE_PERIOD,
|
datetime.datetime.fromisoformat(oo.due_at) + GRACE_PERIOD,
|
||||||
self.scheduled_check
|
self.scheduled_check
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue