RuntimeError: cannot schedule new futures after interpreter shutdown

We Are Going To Discuss About RuntimeError: cannot schedule new futures after interpreter shutdown. So lets Start this Python Article.

RuntimeError: cannot schedule new futures after interpreter shutdown

Advertisements
  1. How to solve RuntimeError: cannot schedule new futures after interpreter shutdown

    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

  2. RuntimeError: cannot schedule new futures after interpreter shutdown

    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

Solution 1

Advertisements

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

Original Author Carl Cheung Of This Content

Solution 2

Advertisements

You may face this issue if your code ends without a blocking loop.
For instance, inside you main.py:

# code start
my_function_submitting_tasks_without_waiting()
# end of file

Instead you can do something like that

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

But of course instead of “while True”, you could use a “while not self._signal_stop:” inside your main class

Original Author Mickael Bolnet Of This Content

Solution 3

Advertisements

In case you are using python-telegram-bot, you might be missing an updater.idle() call after updater.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, also it is a different package. So leaving this for folks that come here, after searching for the above error message.

Original Author anarchist912 Of This Content

Solution 4

Advertisements

Faced the same problem while shutting down the scheduler, .shutdown(wait=False) worked fine.

c = 0
def tick():
    global c
    print(c)
    print('Tick! The time is: %s' %
          datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
    # sleep(5)
    print('After sleep! The time is: %s' %
          datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
    c += 1
    if c == 3:
        # sched.remove_job('my_job_id')
        sched.shutdown(wait=False)


def main():
    sched.add_job(tick, 'interval', seconds=1,
                  next_run_time=datetime.now(),  # start immediately
                  id='my_job_id')
    sched.print_jobs()
    sched.start()

Original Author Sharukh Rahman Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment