ydf0509/funboost

复制文档中《4.4 演示如何定时运行。》代码直接给我报错了

xdbytes opened this issue · 1 comments

15:28:17 "/Users/zhangxiaodong/PycharmProjects/GameFiBridge/tasks/test.py:7" queue_test_666 的消费者
2022-02-07 15:28:20 - apscheduler.scheduler - "/Users/zhangxiaodong/PycharmProjects/GameFiBridge/venv/lib/python3.9/site-packages/apscheduler/schedulers/base.py:988" - _process_jobs - ERROR - Error submitting job "timing_publish_deco.._deco (trigger: interval[0:00:03], next run at: 2022-02-07 15:28:20 CST)" to executor "default"
Traceback (most recent call last):
File "/Users/zhangxiaodong/PycharmProjects/GameFiBridge/venv/lib/python3.9/site-packages/apscheduler/schedulers/base.py", line 979, in _process_jobs
executor.submit_job(job, run_times)
File "/Users/zhangxiaodong/PycharmProjects/GameFiBridge/venv/lib/python3.9/site-packages/apscheduler/executors/base.py", line 71, in submit_job
self._do_submit_job(job, run_times)
File "/Users/zhangxiaodong/PycharmProjects/GameFiBridge/venv/lib/python3.9/site-packages/apscheduler/executors/pool.py", line 28, in _do_submit_job
f = self._pool.submit(run_job, job, job._jobstore_alias, run_times, self._logger.name)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 163, in submit
raise RuntimeError('cannot schedule new futures after '
RuntimeError: cannot schedule new futures after interpreter shutdown

python3.9 会这样,因为主线程没有需要运行的逻辑,apscheduler的 BackgroundScheduler需要判断为代码需要结束, 就会报错了。
使用py3.9时候,可以在代码结尾加个while 1的不让主线程结束,这样不会报错。

image