3 Star 2 Fork 0

opensnail/snail-job-python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
demo_job.py 737 Bytes
一键复制 编辑 原始数据 按行查看 历史
dhb52 提交于 2024-07-12 00:12 . init
import time
from snailjob import SnailJobError, job
from snailjob.log import SnailLog
from snailjob.schemas import ExecuteResult
@job("testJobExecutor")
def test_job_executor(args: str) -> ExecuteResult:
SnailLog.REMOTE.info("sync job1: " + args)
# 执行一个超过40秒的任务,如果中间第30秒可以正常发送心跳,说明任务执行不阻塞
for i in range(40):
SnailLog.REMOTE.info(f"loop {i}")
time.sleep(1)
SnailLog.REMOTE.info("sync job1 done")
return ExecuteResult.success()
@job("testJobExecutorFailed")
def test_job_executor_failed(args: str):
SnailLog.LOCAL.info("testJobExecutorFailed, SnailJobError raised")
raise SnailJobError("这是故意抛出的异常")
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/opensnail/snail-job-python.git
git@gitee.com:opensnail/snail-job-python.git
opensnail
snail-job-python
snail-job-python
master

搜索帮助

Cb406eda 1850385 E526c682 1850385