Created
April 27, 2018 08:00
-
-
Save gwdekker/01902504e2727a4f092b1a48dda1096c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppServerSvc (win32serviceutil.ServiceFramework): | |
_svc_name_ = "TestService" | |
_svc_display_name_ = "Test Service" | |
def __init__(self, args): | |
win32serviceutil.ServiceFramework.__init__(self, args) | |
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) | |
def SvcStop(self): | |
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) | |
win32event.SetEvent(self.hWaitStop) | |
def SvcDoRun(self): | |
servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, | |
servicemanager.PYS_SERVICE_STARTED, | |
(self._svc_name_, '')) | |
self.main() | |
def main(self): | |
try: | |
import download_service64Bit | |
gw = execnet.makegateway("popen//python={}".format(r'C:\Python27_64Bit\python.exe')) | |
channel = gw.remote_exec(download_service64Bit) | |
sleeptime = 1 | |
wait = win32event.WAIT_OBJECT_0 | |
while win32event.WaitForSingleObject(self.hWaitStop, sleeptime * 1000) != wait: | |
channel.send(1) | |
sleeptime = channel.receive() | |
except BaseException as e: | |
# error handling - omitted in snippet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment