def __init__(self, i, in_q, out_q, q_put_interval=0.001): SmqtkObject.__init__(self) threading.Thread.__init__(self, name='[w%d]' % i) self._log.debug("Making thread worker (%d, %s, %s)", i, in_q, out_q) self.i = i self.in_q = in_q self.out_q = out_q self.q_put_interval = q_put_interval self._stop = threading.Event()
def __init__(self, filepath, monitor_interval, settle_window, callback): """ On a separate thread, monitor the modification time of the file at the given file path. When the file is updated (after the file has stopped changing), trigger the provided callback function, given the monitored file path and the file stat event. We initially set ourselves as a daemon as that is the most probable usage of our functionality. :param filepath: Path to the file to monitor :type filepath: str :param monitor_interval: Frequency in seconds at which we check file modification times. This must be >= 0. :type monitor_interval: float :param settle_window: If a recently modified file is not modified again for this many seconds in a row, we consider the file done being modified and trigger the triggers ``callback``. This must be >= 0 and should be >= the ``monitor_interval``. :type settle_window: float :param callback: Callback function that will be triggered every time the provided file has been updated and the settle time has safely expired. :type callback: (str) -> None :raises ValueError: The given filepath did not point to an existing, valid file. """ SmqtkObject.__init__(self) threading.Thread.__init__(self, name=self.__class__.__name__) self.daemon = True self.filepath = filepath self.monitor_interval = monitor_interval self.settle_window = settle_window self.callback = callback self.event_stop = threading.Event() self.event_stop.set() # make sure false self.state = self.STATE_WAITING if not os.path.isfile(self.filepath): raise ValueError("Provided filepath did not point to an existing, " "valid file.") if monitor_interval < 0 or settle_window < 0: raise ValueError("Monitor and settle times must be >= 0")
def __init__(self, filepath, monitor_interval, settle_window, callback): """ On a separate thread, monitor the modification time of the file at the given file path. When the file is updated (after the file has stopped changing), trigger the provided callback function, given the monitored file path and the file stat event. We initially set ourselves as a daemon as that is the most probable usage of our functionality. :param filepath: Path to the file to monitor :type filepath: str :param monitor_interval: Frequency in seconds at which we check file modification times. This must be >= 0. :type monitor_interval: float :param settle_window: If a recently modified file is not modified again for this many seconds in a row, we consider the file done being modified and trigger the triggers ``callback``. This must be >= 0 and should be >= the ``monitor_interval``. :type settle_window: float :param callback: Callback function that will be triggered every time the provided file has been update and the settle time has expired. :type callback: (str) -> None :raises ValueError: The given filepath did not point to an existing, valid file. """ SmqtkObject.__init__(self) threading.Thread.__init__(self, name=self.__class__.__name__) self.daemon = True self.filepath = filepath self.monitor_interval = monitor_interval self.settle_window = settle_window self.callback = callback self.event_stop = threading.Event() self.event_stop.set() # make sure false self.state = self.STATE_WAITING if not os.path.isfile(self.filepath): raise ValueError("Provided filepath did not point to an existing, " "valid file.") if monitor_interval < 0 or settle_window < 0: raise ValueError("Monitor and settle times must be >= 0")
def __init__(self, name, arg_sequences, q, num_terminal_packets, heart_beat, do_fill, fill_value): threading.Thread.__init__(self, name=name) SmqtkObject.__init__(self) if name: self.name = '[' + name + ']' else: self.name = '' self.arg_sequences = arg_sequences self.q = q self.num_terminal_packets = num_terminal_packets self.heart_beat = heart_beat self.do_fill = do_fill self.fill_value = fill_value self._stop = threading.Event()