wip
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""FastAPI admin application."""
|
||||
from __future__ import annotations
|
||||
|
||||
import threading
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import FastAPI
|
||||
@@ -21,6 +22,20 @@ app.mount("/static", StaticFiles(directory=str(_STATIC)), name="static")
|
||||
@app.on_event("startup")
|
||||
def on_startup() -> None:
|
||||
init_db()
|
||||
_start_huey_consumer()
|
||||
|
||||
|
||||
def _start_huey_consumer() -> None:
|
||||
from huey.consumer import Consumer
|
||||
from crawler.tasks import huey
|
||||
|
||||
class _ThreadConsumer(Consumer):
|
||||
def _set_signal_handlers(self) -> None:
|
||||
pass # signal.signal() only works on the main thread
|
||||
|
||||
consumer = _ThreadConsumer(huey, workers=1, periodic=False)
|
||||
t = threading.Thread(target=consumer.run, daemon=True, name="huey-consumer")
|
||||
t.start()
|
||||
|
||||
|
||||
@app.get("/")
|
||||
|
||||
Reference in New Issue
Block a user