代码拉取完成,页面将自动刷新
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("这是故意抛出的异常")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。