Why import in a thread block print

Le
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
  • Partager ce contenu :
Vos réponses
Trier par : date / pertinence
News123
Le #21670571
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
Poster une réponse
Anonyme