Ask coding questions

← Back to all posts
RuntimeError: can't start new thread
PikachuB2005 (8)

(Python) For some reason multiprocessing is unable to create a new thread, and my project won't work because of it. It was just working a few minutes ago, and none of the code has been changed.

(The Scratch code is correct, but you can see it anyway: https://turbowarp.org/511063803/editor . The project won't work in turbowarp because it's database is separate from scratch, but the scratch project is unshared.)

Comments
hotnewtop
Coder100 (16760)

Ok, send the code then?

PikachuB2005 (8)

I thought I selected it. sorry.

PikachuB2005 (8)

It's working now, but sometimes it won't work and I don't know why =(

PikachuB2005 (8)

hmm. Now I just need a timer that resets the loop if it doesn't do anything for a certain period of time.

Coder100 (16760)

Wdym doesn't do anything @PikachuB2005

PikachuB2005 (8)

I have it waiting for a confirmation from the Scratch project. But if someone exits the project before this finishes, it'll wait forever. So I want it to reset the loop if nothing happens. I now how to do this (I think) so... yeah

PikachuB2005 (8)

NEVERMIND.If I have something like this:

import time, multiprocessing
def TimeCheck():
  while True:
    Δt=time.time()-begin_time
    if Δt>60:
      #have error in while True loop so it restarts
    else:
      time.sleep(1)
while True:
  try:
    begin_time=timer.time()
    timer=multiprocessing.Process(target=TimeCheck())
    timer.start()
    #do stuff
    timer.terminate()
  except:
    print('Error')

What can I do to have that error?

PikachuB2005 (8)

oh no I forgot the colon AHHHHH XD
EDIT: I fixed it.

PikachuB2005 (8)

@Coder100 btw it's showing the same error again

PikachuB2005 (8)

@Coder100 I know that there is a limit, but each one is deleted before another is created. So...HOW

Coder100 (16760)

well its threads, maybe there's some cleanup that's happening. Don't forget to use .join() to fully delete a thread @PikachuB2005

PikachuB2005 (8)

if .join() deletes it what does .terminate() do

Coder100 (16760)

well
terminate probably stops execution but .join blocks the main thread until the program exits @PikachuB2005