Python execute task -
this question has answer here:
- how use threading in python? 16 answers
i have python class indefinitely blocking task method
class a(object): def __init__(self): # start task def task(self): while true: #do work
i want start execution of task in constructor of a. need run in own thread task blocking. how in python 2.7?
like mentioned in comments, there's module threading seems fit task. example:
import threading class a(object): def __init__(self): threading.thread(target=self.task).start() def task(self): print 'hello thread' = a() # output: 'hello thread'
Comments
Post a Comment