Thursday 8 December 2016

Python execute task

Like mentioned in comments, there's a module threading that seems to exactly fit your task. Example:



import threading

class A(object):
def __init__(self):
threading.Thread(target=self.task).start()


def task(self):
print 'Hello from a Thread'

a = A()

# output: 'Hello from a Thread'

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...