MCPcopy
hub / github.com/exchangeratesapi/exchangeratesapi / initialize_scheduler

Function initialize_scheduler

exchangerates/app.py:71–90  ·  view source on GitHub ↗
(app, loop)

Source from the content-addressed store, hash-verified

69
70@app.listener("before_server_start")
71async def initialize_scheduler(app, loop):
72 # Check that tables exist
73 await db.gino.create_all()
74
75 # Schedule exchangerate updates
76 try:
77 _ = open("scheduler.lock", "w")
78 fcntl.lockf(_.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
79
80 scheduler = AsyncIOScheduler()
81 scheduler.start()
82
83 # Updates lates 90 days data
84 scheduler.add_job(update_rates, "interval", hours=1)
85
86 # Fill up database with rates
87 count = await db.func.count(ExchangeRates.date).gino.scalar()
88 scheduler.add_job(update_rates, kwargs={"historic": True})
89 except BlockingIOError:
90 pass
91
92
93@app.middleware("request")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected