from celery import Celery
app = Celery()
print(app)
@app.task(name='myfirsttask')
def add(x, y):
print('enter ~~~')
ret = x + y
import time
time.sleep(10)
return ret
print(app.conf)
app.conf.broker_url = 'redis://192.168.106.131:6379/0'
app.conf.broker_transport_options = {'visibility_timeout': 3600*12}
app.conf.result_backend = 'redis://192.168.106.131:6379/1'
app.conf.update(
enable_utc=True,
timezone='Asia/Shanghai',
)
if __name__ == '__main__':
# add(7, 8)
add.delay(3, 4)
add.apply_async((10, 20), countdown=5)
print('~~~')
terminal
celery -A tt1 worker -P eventlet --loglevel=INFO --concurrency=5 -n worker1@%n