def dectheclass(cls): if ru.is_main_thread(): cprof_env = os.getenv("RADICAL_PILOT_CPROFILE_COMPONENTS", "") cprof_elems = cprof_env.split() if "CONTINUOUS" in cprof_elems: for name, m in inspect.getmembers(cls, inspect.ismethod): setattr(cls, name, dec(m)) return cls
def kill(self): assert(ru.is_main_thread()) assert(self.is_parent) assert(not self.killed) self.killed = True signal.kill(self.child, signal.SIGUSR2)
def stop(self): assert(ru.is_main_thread()) assert(self.is_parent) assert(not self.stopped) self.stopped = True self.term.set() print '%-10s : stop watcher' % self.uid self.watcher.stop() ret = ru.watch_condition(target=False, cond=self.watcher.is_alive, timeout=15) if not ret: print '%-10s : could not stop watcher - kill' % self.uid self.watcher.kill() self.watcher.join() print '%-10s : watcher stopped' % self.uid
def __init__(self, name, cfg, term, verbose): mt.Thread.__init__(self) self.uid = name self.verbose = verbose self.log = ru.get_logger('radical.' + self.uid, level=verbose) self.cfg = cfg self.term = term ru.raise_on('init') # we don't allow subsubthreads # FIXME: this could be lifted, but we leave in place and # re-evaluate as needed. if not ru.is_main_thread(): raise RuntimeError('threads must be spawned by MainThread [%s]' % \ ru.get_thread_name())