0

I'm using Portable Python 3.9.4 x64 on Windows and everytime I'm calling the time.sleep(...)-method the Thread exits and won't return:

import threading
import time

threads = []
print ("hello")

class myThread(threading.Thread):
    def __init__(self, i):
        threading.Thread.__init__(self)
        self.i = i

    def run(self):
        print ("i = ", self.i)
        for j in range(0, self.i):
            print ("i: ", i,"j = ",j)
            time.sleep(5)

for i in range(1,4):
    thread = myThread(i)
    thread.daemon = False
    thread.start()

My Output is:

hello
i =  1
i:  1 j =  0
i =  2
i:  2 j =  0
i =  3
i:  3 j =  0

If I'm using shorter delays like time.sleep(0.05) then I get more values for j, but still not all of them. So I guess all threads are killed, because the main-thread finishes. But how can I keep the threads running? The daemon-attribute seems not to change anything...

1 Answers1

0

I think that there is a problem with your time.py module file. If you're using local, redownload the file or if you're online, try contacting and reporting this.

  • Ehm, I'm not sure, how to do this, or if this is possible: https://stackoverflow.com/questions/42522650/cant-install-time-module/46658551 Can you give me an advice, please? – Benedikt Lindemann Sep 19 '21 at 10:34
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-ask). – Community Sep 19 '21 at 10:52