| | |
| | | from time import sleep |
| | | import uuid |
| | | import subprocess |
| | | #from trisurf import trisurf |
| | | import os |
| | | import shutil |
| | | import signal |
| | | import sys |
| | | import socket |
| | | from threading import Thread, Event |
| | | """ |
| | | p=None |
| | | workingdir=None |
| | | |
| | | |
| | | |
| | | #--- SIGINT and SIGTERM HANDLING --- |
| | | def signal_handler(signal,frame): |
| | | global p |
| | | global wirkingdir |
| | | if p is not None: |
| | | p.terminate() |
| | | if(workingdir is not None): |
| | | removeDir(workingdir.fullpath()) |
| | | print("Process ended with signal " +str(signal)) |
| | | sys.exit(0) |
| | | signal.signal(signal.SIGINT, signal_handler) |
| | | signal.signal(signal.SIGTERM, signal_handler) |
| | | #--- END SIGINT and SIGTERM---- |
| | | """ |
| | | |
| | | |
| | | def get_hostname(): |
| | | return socket.gethostname() |
| | |
| | | self.id=subid |
| | | self.ip=get_ip() |
| | | self.hostname=get_hostname() |
| | | self.update_seconds=update_seconds |
| | | self.update_seconds=update_second |
| | | # self.subthreads=[] |
| | | |
| | | def stop(self): |
| | | self._stop_event.set() |
| | |
| | | |
| | | |
| | | |
| | | |
| | | #--- SIGINT and SIGTERM HANDLING --- |
| | | def signal_handler(signal,frame): |
| | | t.stop() |
| | | t.join() |
| | | print("Process ended with signal " +str(signal)) |
| | | sys.exit(0) |
| | | sys.exit(signal) |
| | | #--- END SIGINT and SIGTERM---- |
| | | |
| | | if __name__ == '__main__': |