准备工作
(1) 环境
@J1 server, CentOS7.9
$ which gcc
/home/wangjl/soft/gcc-12.3.0/bin/gcc
$ which python3
/home/wangjl/soft/python3/python-3.10.14/bin/python3
$ gcc --version
gcc (GCC) 12.3.0
Copyright (C) 2022 Free Software Foundation, Inc.
$ python3 -V
Python 3.10.14
(2) 准备
$ pip3 install celery
$ pip3 install redis
$ pip3 list | grep celery
celery 5.4.0
$ pip3 list | grep redis
redis 5.0.5
启动redis服务:
$ redis-server --version
Redis server v=6.2.6 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=3ee1339f93e3f95a
$ redis-server
…
76382:M 12 Jun 2024 16:54:15.813 * Ready to accept connections
启动服务后才能连接:
$ redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> quit
$
1. 定义任务
$ cat task02.py
from celery import Celery
import