def _assert_pid_not_reused(fun):
 @functools.wraps(fun)
 def wrapper(self, *args, **kwargs):
  if (not self.is_running()):
   raise NoSuchProcess(self.pid, self._name)
  return fun(self, *args, **kwargs)
 return wrapper

def _assert_pid_not_reused ( fun ) : @ functools . wraps ( fun ) def wrapper ( self , * args , ** kwargs ) : if ( not self . is_running ( ) ) : raise NoSuchProcess ( self . pid , self . _name ) return fun ( self , * args , ** kwargs ) return wrapper
decorator which raises nosuchprocess in case a process is no longer running or its pid has been reused .