### 原理:
gevent有个spawn_later()函数,专为定时任务打造...
他的`缺点`就是,别让gevent调度堵塞了....尽量让你业务逻辑,采用gevent patch模块
正在尝试下,借助spawn_later周期功能,解决堵塞的问题, [查看更多GeventCron相关信息](http://xiaorui.cc)
### 安装方法:
```
pip install geventcron
or
python setup.py install
```
### 使用方法:
```
import time
import requests
import threading
import functools
from datetime import datetime
import geventcron
def async(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
my_thread = threading.Thread(target=func, args=args, kwargs=kwargs)
my_thread.start()
return wrapper
@async
def func_1():
print 'Call func_1'
def func_2():
print 'Call func_2'
def func_3():
print 'Call func_3'
#尽量别用堵塞的模块,可以用grequests
def block():
requests.get("http://www.google.com/")
if __name__ == "__main__":
scheduler = geventcron.Scheduler(logger_name='task_scheduler')
scheduler.schedule('task_1', geventcron.Interval("*/1 * * * *"), func_1)
scheduler.schedule('task_2', geventcron.Interval(2), func_2)
scheduler.schedule('task_3', geventcron.Interval(3), func_3)
# scheduler.run_forever()
scheduler.daemon(flag=True)
print "daemon"
time.sleep(100)
```
Metadata
Release files for geventcron 1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| geventcron-1.5.tar.gz | 3.4 kB | Without provenance | Details for geventcron-1.5.tar.gz |
Release files / geventcron-1.5.tar.gz
| Download URL | geventcron-1.5.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
41dda168ebe2126ff1b78142c5f34048b27497f5afad5be62da05d92e87c48c9
|
|
BLAKE2b-256 checksum How to use checksums |
12552543b9195007c5e346a5dec811ae029e51dea44ec63577a6b2094abcd3df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for geventcron 1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.