quarks
quarks

Reputation: 35282

Celery REST API

Is there a way to use Celery for:

  1. Queue a HTTP call to external URL with Form parameters (HTTP Post to URL)
  2. The external URL will respond HTTP response, 200, 404, 400 etc, if response is in form of error non-200-ish response it will retry for a certain number of retry and will retire as needed
  3. Add Task / Job / Work queue into Celery using REST API, passing the URL to call and Form parameters

Upvotes: 6

Views: 11558

Answers (3)

Bajaj_Dk
Bajaj_Dk

Reputation: 75

you can use flower rest API to do the same, as flower is a monitoring tool for celery. But it comes with rest api to add task and all

https://flower.readthedocs.io/en/latest/index.html

Upvotes: 2

Cedric
Cedric

Reputation: 111

  1. For that you need to create a task in your celery application that would perform that request for you and return the result.
  2. Handling the errors and retries can be done within the code of your task, or can alternatively be taken care by celery if you schedule the task with the right arguments: see the arguments of .apply_async()
  3. You can schedule new tasks via REST API if you run Celery Flower. It has a REST API (see documentation), in particular a POST endpoint to schedule a task.

Upvotes: 4

Evhz
Evhz

Reputation: 9246

Yes, create an I/O class that handle your http requests and process.
Read about celery tasks and remember to set connect_timeout= 5.0, read_timeout = 30.0 timeouts to your I/O ops to not block your workers.

There is a precise example of using requests in the celery worker tasks.

Upvotes: 2

Related Questions