Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Why import in a thread block print

1 réponse
Avatar
Chris
Hi all,

Why import math block the thread (print is not continuous) ?
When i remove "import math", the print continue infinitely.

class SyncTopAppel(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.running = False
def run(self):
self.running = True
while self.running:
print "before"
import math
print "after"
time.sleep(1)
def stop(self):
self.running = False

Thanks

1 réponse

Avatar
News123
Chris wrote:
Hi all,

Why import math block the thread (print is not continuous) ?
When i remove "import math", the print continue infinitely.

class SyncTopAppel(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.running = False
def run(self):
self.running = True
while self.running:
print "before"
import math
print "after"
time.sleep(1)
def stop(self):
self.running = False

Thanks



Est-ce que ca marche, si tu fa sune import avant?

Je creoix, que j'ai lu de certains problemes avec les imports dans le
threads, mais je ne suis pas sur.



essay quand meme:

import math

class SyncTopAppel(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.running = False
def run(self):
self.running = True
while self.running:
print "before"
import math
print "after"
time.sleep(1)
def stop(self):
self.running = False