mirror of
https://github.com/hequan2017/seal.git
synced 2026-04-07 04:47:38 +08:00
0.1.1 增加异步程序 选择
This commit is contained in:
10
README.md
10
README.md
@@ -48,7 +48,7 @@ python manage.py createsuperuser
|
||||
python manage.py runserver 0.0.0.0:80
|
||||
|
||||
```
|
||||
* 扩展功能
|
||||
* 扩展功能-异步1 推荐 定时任务用celery
|
||||
```bash
|
||||
#需要安装redis
|
||||
#启动celery异步任务
|
||||
@@ -56,6 +56,14 @@ cd seal
|
||||
celery -B -A seal worker -l info
|
||||
```
|
||||
|
||||
* 扩展功能-异步2 普通异步任务 用 dramatiq
|
||||
```bash
|
||||
cd system/decorator/asynchronous/
|
||||
dramatiq asynchronous --watch . --log-file /tmp/dramatiq.log
|
||||
|
||||
```
|
||||
|
||||
|
||||
## 注意
|
||||
* 如果想直接拿来做生产项目,请重新生成一个 settings 文件里面的 SECRET_KEY
|
||||
* 时区问题
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
amqp==2.4.2
|
||||
argh==0.26.2
|
||||
backcall==0.1.0
|
||||
billiard==3.5.0.5
|
||||
celery==4.2.1
|
||||
@@ -9,23 +10,31 @@ Django==2.1.7
|
||||
django-bootstrap4==0.0.7
|
||||
django-celery-beat==1.4.0
|
||||
django-celery-results==1.0.4
|
||||
django-crispy-forms==1.7.2
|
||||
django-pure-pagination==0.3.0
|
||||
django-timezone-field==3.0
|
||||
dramatiq==1.5.0
|
||||
gevent==1.4.0
|
||||
greenlet==0.4.15
|
||||
idna==2.8
|
||||
ipython==6.4.0
|
||||
ipython-genutils==0.2.0
|
||||
jedi==0.12.0
|
||||
jsonfield==2.0.2
|
||||
kombu==4.4.0
|
||||
mysqlclient==1.4.2.post1
|
||||
parso==0.2.1
|
||||
pathtools==0.1.2
|
||||
pexpect==4.6.0
|
||||
pickleshare==0.7.4
|
||||
prometheus-client==0.2.0
|
||||
prompt-toolkit==1.0.15
|
||||
ptyprocess==0.5.2
|
||||
Pygments==2.2.0
|
||||
python-crontab==2.3.6
|
||||
python-dateutil==2.8.0
|
||||
pytz==2018.4
|
||||
PyYAML==5.1
|
||||
redis==3.2.0
|
||||
requests==2.21.0
|
||||
simplegeneric==0.8.1
|
||||
@@ -33,4 +42,6 @@ six==1.11.0
|
||||
traitlets==4.3.2
|
||||
urllib3==1.24.1
|
||||
vine==1.2.0
|
||||
wcwidth==0.1.7
|
||||
watchdog==0.8.3
|
||||
watchdog-gevent==0.1.0
|
||||
wcwidth==0.1.7
|
||||
|
||||
0
system/decorator/asynchronous/__init__.py
Normal file
0
system/decorator/asynchronous/__init__.py
Normal file
12
system/decorator/asynchronous/asynchronous.py
Normal file
12
system/decorator/asynchronous/asynchronous.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import dramatiq
|
||||
import requests
|
||||
from dramatiq.brokers.redis import RedisBroker
|
||||
|
||||
redis_broker = RedisBroker(host="127.0.0.1", port=6379)
|
||||
dramatiq.set_broker(redis_broker)
|
||||
|
||||
@dramatiq.actor
|
||||
def count_words(url):
|
||||
print(url)
|
||||
|
||||
count_words.send("http://example.com")
|
||||
Reference in New Issue
Block a user