from__future__importannotations# For type hinting before definition, ref: https://stackoverflow.com/questions/33533148/how-do-i-specify-that-the-return-type-of-a-method-is-the-same-as-the-class-itsel
self._thread.daemon=True# thread dies with the program
self._thread.daemon=True# thread dies with the program
self._thread.start()
# wait for service to start
foriinrange(0,10):
foriinrange(0,10):
time.sleep(1.0)
# self.procIpcBatch() # don't pump message during start up
print("_zz_",end="",flush=True)
ifself._status==MainExec.STATUS_RUNNING:
ifself._status==MainExec.STATUS_RUNNING:
logger.info("[] TDengine service READY to process requests")
return# now we've started
raiseRuntimeError("TDengine service did not start successfully")# TODO: handle this better?
return# now we've started
# TODO: handle this better?
raiseRuntimeError("TDengine service did not start successfully")
defstop(self):
# can be called from both main thread or signal handler
print("Terminating TDengine service running as the sub process...")
ifself.isStopped():
print("Service already stopped")
return
return
ifself.isStopping():
print("Service is already being stopped")
return
# Linux will send Control-C generated SIGINT to the TDengine process already, ref: https://unix.stackexchange.com/questions/176235/fork-and-how-signals-are-delivered-to-processes
ifnotself._tdeSubProcess:
# Linux will send Control-C generated SIGINT to the TDengine process