code: def eventloop(self, *args, **kwargs):
          
  
          # Setting status
          status = None
  
          # Starting the clock
          start = time.time()
  
          first_loop = True
          # loop running target, maybe more than once
          while not self.exit.is_set():
  
              if first_loop:
                  first_loop = False
                  # signalling startup only the first time, just after having check for exit request.
                  # We need to return control before starting, but after entering context...
                  self.started.set()
                  # TODO : check if better outside of loop maybe ??
                  # It will change semantics, but might be more intuitive...
  
              # time is ticking
              # TODO : move this out of here. this class should require only generic interface to any method.
              now = time.time()
              timedelta = now - start
              start = now
  
              # replacing the original Process.run() call, passing arguments to our target
              if self._target:
                  # bwcompat
                  kwargs['timedelta'] = timedelta
  
                  # TODO : use return code to determine when/how we need to run this the next time...
                  # Also we need to keep the exit status to be able to call external process as an update...
  
                  logging.debug(
                      "[{self.name}] calling {self._target.__name__} with args {args} and kwargs {kwargs}...".format(
                          **locals()))
                  status = self._target(*args, **kwargs)
  
              if status is not None:
                  break
  
          if self.started.is_set() and status is None and self.exit.is_set():
              # in the not so special case where we started, we didnt get exit code and we exited,
              # this is expected as a normal result and we set an exitcode here of 0
              # As 0 is the conventional success for unix process successful run
              status = 0
  
          return status
docs: Hand crafted event loop, with only one event possible : exit
          More events ( and signals ) can be added later, after converting to asyncio.