sam
sam

Reputation: 1019

How to create a service in Python in Windows?

I have found http://code.activestate.com/recipes/576451-how-to-create-a-windows-service-in-python/

But that service does nothing. How can I use that service for running specific Python file?

Upvotes: 0

Views: 378

Answers (1)

atzz
atzz

Reputation: 18010

You can put your business code in SvcDoRun. The sample at your link just logs a message every three seconds. Just don't forget to check self.hWaitStop periodically.

Sometimes it is convenient to create a worker thread and do all work on that thread, or maybe start a child process. An additional complication in this case is that you have to think about synchronization.

Upvotes: 1

Related Questions