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

Flask extension not registered in app.extensions
TensorFlow - Ignore infinite values when calculating the mean of a tensor
Using %matplotlib notebook after %matplotlib inline in Jupyter Notebook doesn't work
Translate Tcl List to Python List
Selenium unable to locate element that it has already located
Wrong result in `netaddr`'s `IPRange.__contains__` (`in`) operator
How to pass any Google API service object to a deferred task in App Engine?
Getting a simple plot in Tensorboard
How to generate a float or double list using range()? [duplicate]
Should binary features be one-hot encoded?
Prepopulate ModelForm fields based on referring URL
How to get syntax highlighting for .enaml files in PyCharm?
regex for python to change a set of char
How to identify customer with stripe webhook in Python/Flask
How to correctly implement a game manager in Python
How to convert a set of gps points to GPX file

Categories

HOME
xbox-live
mapping
nuxeo
jasmine
laravel-5.2
angular2-directives
ruby-on-rails-3
specflow
gspread
yocto
shipping
constructor
criteria
gatsby
dlib
simple-injector
uisplitviewcontroller
ssms-2016
uicollectionview
flat-file
thumbnails
device-detection
ip-camera
jconsole
nmake
dspic
philips-hue
read-write
consumer
outsystems
swiftcharts
pljson
modulo
rhino
large-data
remote-server
pox
ksoap
magiczoomplus
haskell-pipes
installshield-2012
infusionsoft
dart-pub
control-flow-graph
jrules
tango
facebook-chatbot
prototypejs
startapp
defold
livescribe
crystal-reports-8.5
forerunnerdb
gce
redux-router
settimeout
galleriffic
aescryptoserviceprovider
firepath
clob
date-format
elastix
concur
insert-into
application-loader
sourcegear-vault
digits
git-checkout
scrollspy
jazz
jython-2.7
c++-actor-framework
sysctl
rhel5
sortable
boost-test
wss
broadcasting
ksoap2
circos
hamsterdb
bignum
facebook-sdk-3.1
vertical-rhythm
nimrod
goinstant
windows-update
localtime
manage.py
reporting-tools
phpsh
ubuntu-11.10
responsetext
v4l
shared-objects
noir
smooth
revert
internals
odbc-sql-server-driver
opcodes
castle-validators
self-reference
associativity

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