code: def wait_for_term():
      
  
      class Waiter:
  
          def __init__(self):
              self.sleeping = True
              import signal #@Reimport
              self.oldhandler = signal.signal(signal.SIGTERM,
                                              self._SIGTERMHandler)
  
          def _SIGTERMHandler(self, number, frame):
              self.sleeping = False
  
          def sleep(self):
              while self.sleeping:
                  time.sleep(0.1)
  
      waiter = Waiter()
      waiter.sleep()
docs: Wait until we get killed by a TERM signal (from someone else).