python


Celery - How to send task from remote machine?


We have a server running celery workers and a Redis queue. The tasks are defined on that server.
I need to be able to call these tasks from a remote machine.
I know that it is done using send_task but I still haven't figured out HOW? How do I tell send_task where the queue is? Where do I pass connection params (or whatever needed)? I've been looking for hours and all I can find is this:
from celery.execute import send_task
send_task('tasks.add')
Well, that means that I need celery on my calling machine as well. But what else do I need to set up?
This may be a way:
Creating a Celery object and using send_task from that object, the object can have the configuration to find the broker.
from celery import Celery
celery = Celery()
celery.config_from_object('celeryconfig')
celery.send_task('tasks.add', (2,2))
celeryconfig is a file containing the celery configuration, there are other ways set config on the celery object.
There are several ways to define routing rules, the most general of which is the custom router object. In all cases, the caller just provides a routing_key parameter in send_task, delay or apply_async and the router determines which queue to send the task into.
on the remote machine, start up celery with the broker_url pointing to the machine you want to run the tasks on. Then just submit the tasks (if you have specific queues to submit to, then add the appropriate routing keys).
What you found was right.
from celery.execute import send_task
send_task('tasks.add')
If any args needed
send_taks('tasks.add', kwargs={'a'=1, 'b'=2})

Related Links

ValueError in tests permission in django
How are conflicting 'from x import *' imports resolved?
Creating a short alias for imported variable - import types.SimpleNamespace as Ns not working
What rows are in view of a QAbstractTableModel
removing entries from a numpy array
Distribute remote_api_shell .py requests among many instances
Doing camera calibration by having intrinsic matrix and distortion coefficients in OPENCV and in real-time video
Receiving a traceback on opencv opening images with python?
How to understand closure in a lambda?
Python: Pickle error with SVM usage
How to use conda to install Github package specutils?
Find Multiple Flagged String within String Python
Create a new numpy array with values based on coordinates and external variables
Counting the Number of Frames in a Video file using OpenCV?
How to create 2 actions with same path but different HTTP methods DRF
Inconsistent results using ALS in Apache Spark

Categories

HOME
arrays
cakephp-3.x
answer-set-programming
mapping
json-ld
javamail
propertygrid
google-spreadsheet-api
eval
flexbox
window
xamarin-studio
ndis
wordpress-theming
hashicorp-vault
nuxt.js
symfony-forms
react-leaflet
tarantool
delete-file
bcrypt
shopping-cart
java-ee-7
branch
lync-2013
hash-collision
rhandsontable
fetch-api
bitcoin-testnet
rowcount
graph-databases
oracle-xml-db
data-extraction
rhomobile
nsurlconnection
phpspreadsheet
von-neumann
swagger-editor
fltk
wsadmin
google-account
pytest-django
azure-availability-set
mouseclick-event
goquery
decompress
nuget-server
pagefile
jszip
bettercms
project-template
iostat
windows-azure-pack
tomee
radians
freetype2
nssplitview
kendo-combobox
flexjson
fortran90
jta
textkit
castle-windsor-3
musl
multipleselection
scala-2.11
firebug-lite
libssh2
system.web
surrogate-key
spdy
phpdocx
map-force
sim900
bigint
sslexception
lame
symphony-cms
crocodoc
maven-ear-plugin
pstree
caliper
makefile-project
entity-framework-ctp5
nssavepanel
cross-domain-policy
objectbrowser
electronic-signature
smooth
exitstatus
open-graph-beta
unreachable-code
idictionary
pci-bus
front-controller
webrat
plinq
handheld

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App