31 lines
664 B
Python
31 lines
664 B
Python
|
import sys
|
||
|
|
||
|
from aiohttp import ClientSession
|
||
|
from config import settings as sett
|
||
|
from printing import sent_to_printer
|
||
|
from settings import settings
|
||
|
|
||
|
sys.path.extend(["./"])
|
||
|
|
||
|
|
||
|
async def startup(ctx):
|
||
|
ctx["session"] = ClientSession()
|
||
|
print(f"Worker listening for: {sett.QUEUE_NAME}")
|
||
|
# print(f"Worker printing on: {sett.WORKER_PRINTER_ADDRESS}")
|
||
|
|
||
|
|
||
|
async def shutdown(ctx):
|
||
|
await ctx["session"].close()
|
||
|
|
||
|
|
||
|
class WorkerSettings:
|
||
|
"""
|
||
|
Settings for the ARQ worker.
|
||
|
"""
|
||
|
|
||
|
queue_name = f"barker:print:{sett.QUEUE_NAME}"
|
||
|
redis_settings = settings
|
||
|
functions: list = [sent_to_printer]
|
||
|
on_startup = startup
|
||
|
on_shutdown = shutdown
|