Skip to content

Scaffolding for running Python programs as Windows NT Services

License

Notifications You must be signed in to change notification settings

pacopablo/pywinservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pywinservice

Scaffolding for running Python programs as Windows NT Services

Usage

from pywinservice import NTService, NTServiceThread, handle_command_line

class MyServiceThread(NTServiceThread):

    def run (self):
        while self.notifyEvent.isSet():
            # do stuff here.  be careful not to block, however, as that will
            # cause the service to hang when shutting down
            continue


class MyService(NTService):
    _svc_name_ = 'myservice'            # used in "net start/stop"
    _svc_display_name_ = "My Service"
    _svc_description_ = "This is what My Service does"
    _svc_thread_class = MyServiceThread


if __name__ == '__main__':
    handle_command_line(MyService)

The service can then be installed via the command line with:

python myservice.py --install

Notes

About

Scaffolding for running Python programs as Windows NT Services

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages