I’m programming a python robot in the telegram, but I have an error that is not resolved, the error is in the schedule
Traceback (most recent call last):
File "C:Usersvini6AppDataLocalPackagesPythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0LocalCachelocal-packagesPython39site-packagesapschedulerschedulersbase.py", line 979, in _process_jobs
executor.submit_job(job, run_times)
File "C:Usersvini6AppDataLocalPackagesPythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0LocalCachelocal-packagesPython39site-packagesapschedulerexecutorsbase.py", line 71, in submit_job
self._do_submit_job(job, run_times)
File "C:Usersvini6AppDataLocalPackagesPythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0LocalCachelocal-packagesPython39site-packagesapschedulerexecutorspool.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 FilesWindowsAppsPythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0libconcurrentfuturesthread.py", line 169, in submit
raise RuntimeError('cannot schedule new futures after '
RuntimeError: cannot schedule new futures after interpreter shutdown
5
Answers
It’s bug or something of python 3.9.9. I also came across this issue. But it works well on python 3.7 and python 3.8. Not sure if any other python3.9.x works
Update on 2022/02/11, this issue exists from python3.9 to python 3.10
In case you are using python-telegram-bot, you might be missing an
updater.idle()
call afterupdater.start_polling()
I reported a bug here, and got this solution as a reply, which fixed it for me. I had the very same error message, although it is a different package here. So leaving this for folks that come here, after searching for the above error message.
You may face this issue if your code ends without a blocking loop.
For instance, inside you main.py:
Instead you can do something like that
But of course instead of "while True", you could use a "while not self._signal_stop:" inside your main class
Faced the same problem while shutting down the scheduler,
.shutdown(wait=False)
worked fine.Well, i have faced the same issue as of 28-Jun-2022 and landed here while searching.
After some trial and error i have found some work around which works for me as of now.
Solution 1 (trick)
What we need is to stop the program to exit. So adding some pause at the end worked for me. Here the example is with BackgroundScheduler but any Non-blocking Scheduler will have same approach.
Solution 2
Use BlockingScheduler instead of BackgroundScheduler