Threading problem (doesn`t respect wait or time.sleep)?

Asked by Milteven

I`m trying to run 2 different functions using thread together with a main script but when the script initiates the Java SE just stop working.
To analyze the problem I made a test script with just one thread and a simple function BUT i f you run the code, you will se that he just goes crazy (Opens a HUGE amount of pop ups) and doesn't wait the 2 seconds.
Code below:

import threading
import time

def trocador_conta():

    threading.Thread(target=trocador_conta).start()
    #inicia o thread
    for x in range (1,3):
        popup ('Counter in:%d')%(x)
        time.sleep(2) #waits 2 seconds to popup again
print ('end trocador')

trocador_conta()

Someone has a idead of what is wrong?
Thank you, have a good day!

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

def trocador_conta():
    for x in range (1,3):
        popup ('Counter in:%d')%(x)
        time.sleep(2) #waits 2 seconds to popup again
    print ('end trocador')

threading.Thread(target=trocador_conta).start() #inicia o thread

Revision history for this message
Milteven (milteven12) said :
#2

Thanks RaiMan, that solved my question.