41 lines
1.2 KiB
Python
Executable File
41 lines
1.2 KiB
Python
Executable File
from celery import Celery
|
|
from kombu import Queue, Exchange
|
|
import environ
|
|
env = environ.Env(
|
|
DEBUG=(bool, True)
|
|
)
|
|
|
|
app: Celery = Celery(
|
|
"postman",
|
|
broker= env.str("CELERY_BROKER", "amqp://test:test@rabbitmq:5672"),
|
|
# backend="rpc://",
|
|
include=[
|
|
"celery_worker.mock_process_tasks",
|
|
],
|
|
broker_transport_options={'confirm_publish': True},
|
|
)
|
|
task_exchange = Exchange("default", type="direct")
|
|
task_create_missing_queues = False
|
|
app.conf.update(
|
|
{
|
|
"result_expires": 3600,
|
|
"task_queues": [
|
|
Queue("id_card"),
|
|
Queue("driver_license"),
|
|
Queue("invoice"),
|
|
Queue("ocr_with_box"),
|
|
Queue("template_matching"),
|
|
],
|
|
"task_routes": {
|
|
"process_id": {"queue": "id_card"},
|
|
"process_driver_license": {"queue": "driver_license"},
|
|
"process_invoice": {"queue": "invoice"},
|
|
"process_ocr_with_box": {"queue": "ocr_with_box"},
|
|
"process_template_matching": {"queue": "template_matching"},
|
|
},
|
|
}
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
argv = ["celery_worker.worker", "--loglevel=INFO", "--pool=solo"] # Window opts
|
|
app.worker_main(argv) |