Creating a daemon process in Python
Benjamin Niemann
pink at odahoda.de
Wed Feb 21 17:34:49 EST 2007
garrickp at gmail.com wrote:
> 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.
That's not a daemon process (which are used to execute 'background services'
in UNIX environments).
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
More information about the Python-list
mailing list