def WaitForServiceStatus(serviceName, status, waitSecs, machine=None):
 for i in range((waitSecs * 4)):
  now_status = QueryServiceStatus(serviceName, machine)[1]
  if (now_status == status):
   break
  win32api.Sleep(250)
 else:
  raise pywintypes.error, (winerror.ERROR_SERVICE_REQUEST_TIMEOUT, 'QueryServiceStatus', win32api.FormatMessage(winerror.ERROR_SERVICE_REQUEST_TIMEOUT)[:(-2)])

def WaitForServiceStatus ( serviceName , status , waitSecs , machine = None ) : for i in range ( ( waitSecs * 4 ) ) : now_status = QueryServiceStatus ( serviceName , machine ) [ 1 ] if ( now_status == status ) : break win32api . Sleep ( 250 ) else : raise pywintypes . error , ( winerror . ERROR_SERVICE_REQUEST_TIMEOUT , 'QueryServiceStatus' , win32api . FormatMessage ( winerror . ERROR_SERVICE_REQUEST_TIMEOUT ) [ : ( - 2 ) ] )
waits for the service to return the specified status .