Creating a daemon process in Python
garrickp at gmail.com
garrickp at gmail.com
Wed Feb 21 17:06:36 EST 2007
On Feb 21, 9:33 am, Eirikur Hallgrimsson <e... at mad.scientist.com>
wrote:
> Sakagami Hiroki wrote:
> > What is the easiest way to create a daemon process in Python?
I've found it even easier to use the built in threading modules:
import time
t1 = time.time()
print "t_poc.py called at", t1
import threading
def im_a_thread():
time.sleep(10)
print "This is your thread speaking at", time.time()
thread = threading.Thread(target=im_a_thread)
thread.setDaemon(True)
thread.start()
t2 = time.time()
print "Time elapsed in main thread:", t2 - t1
Of course, your mileage may vary.
More information about the Python-list
mailing list