This is a forked repository from Github and when I try to deploy it to Heroku it shows the error:
2023-12-31T03:10:27.965787+00:00 app[web.1]:
2023-12-31T03:10:27.965828+00:00 app[web.1]: RuntimeError: can't create new thread at interpreter shutdown
2023-12-31T03:10:27.965992+00:00 app[web.1]: self._executor.open()
2023-12-31T03:10:27.966013+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/pymongo/periodic_executor.py", line 87, in open
2023-12-31T03:10:27.966072+00:00 app[web.1]: thread.start()
2023-12-31T03:10:27.966088+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/threading.py", line 992, in start
2023-12-31T03:10:27.966229+00:00 app[web.1]: _start_new_thread(self._bootstrap, ())
2023-12-31T03:10:27.966249+00:00 app[web.1]: RuntimeError: can't create new thread at interpreter shutdown
2023-12-31T03:10:28.174616+00:00 heroku[web.1]: Process exited with status 1
2023-12-31T03:10:28.197914+00:00 heroku[web.1]: State changed from starting to crashed
It says:
RuntimeError: can't create new thread at interpreter shutdown"
Help me to solve this.
I'm trying to create a Telegram bot using that Github repo
Python 3.12 introduced a change that prevents creating new threads after the main thread has exited. It's not clear yet whether it is considered a bug and will be reverted. See CPython issue #115533 for details.
Thread.join()method on any child threads, or converting the thread spawning to usewith ThreadPoolExecutor() as executor: ...(see documentation), which automatically waits at the end of the block.