【问题标题】:RuntimeError: cannot schedule new futures after interpreter shutdownRuntimeError:解释器关闭后无法安排新的期货
【发布时间】:2022-01-11 20:39:17
【问题描述】:

我正在电报中编写一个python机器人,但是我有一个错误没有解决,错误在计划中

Traceback (most recent call last):
  File "C:\Users\vini6\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\apscheduler\schedulers\base.py", line 979, in _process_jobs
    executor.submit_job(job, run_times)
  File "C:\Users\vini6\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\apscheduler\executors\base.py", line 71, in submit_job
    self._do_submit_job(job, run_times)
  File "C:\Users\vini6\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\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 "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\concurrent\futures\thread.py", line 169, in submit
    raise RuntimeError('cannot schedule new futures after '
RuntimeError: cannot schedule new futures after interpreter shutdown

【问题讨论】:

  • 你在使用 python-telegram-bot 吗?

标签: python windows telegram apscheduler


【解决方案1】:

这是 python 3.9.9 的错误或东西。我也遇到过这个问题。但它在 python 3.7 和 python 3.8 上运行良好。不确定其他 python3.9.x 是否有效

2022/02/11更新,从python3.9到python 3.10都存在这个问题

【讨论】:

  • 这可能不是错误。请看我的回答。
  • 有趣,我在 python 3.9 上也遇到了同样的异常
  • @anarchist912 但我没有使用 python-telegram-bot。如果不是bug,那么python显然修改了一些低级的东西,所以原来的方法已经不行了。
【解决方案2】:

如果您的代码在没有阻塞循环的情况下结束,您可能会遇到此问题。 例如,在你的 main.py 中:

# code start
my_function_submitting_tasks_without_waiting()
# end of file

相反,您可以做类似的事情

# code start
my_function_submitting_tasks_without_waiting()
while True:
  pass
# end of file

当然,您可以在主类中使用“while not self._signal_stop:”来代替“while True”

【讨论】:

    【解决方案3】:

    如果您使用的是python-telegram-bot,您可能会在updater.start_polling() 之后错过一个updater.idle() 调用

    我报告了一个错误here,并得到了这个解决方案作为回复,它为我修复了它。我收到了同样的错误信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-01
      • 2013-04-22
      • 2021-04-07
      • 2011-11-22
      • 2011-03-31
      • 2020-07-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多