当前位置: 首页>>代码示例>>Python>>正文


Python Thread.start方法代码示例

本文整理汇总了Python中threading.Thread.start方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.start方法的具体用法?Python Thread.start怎么用?Python Thread.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在threading.Thread的用法示例。


在下文中一共展示了Thread.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: filter_by_tag

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import start [as 别名]
def filter_by_tag(self, tag):
        """
        Filter incoming events by the given ``tag``.

        ``tag`` is a byte or unicode string with the name of a tag.  Only
        events for devices which have this tag attached pass the filter and are
        handed to the caller.

        Like with :meth:`filter_by` this filter is also executed inside the
        kernel, so that client processes are usually not woken up for devices
        without the given ``tag``.

        .. udevversion:: 154

        .. versionadded:: 0.9

        .. versionchanged:: 0.15
           This method can also be after :meth:`start()` now.
        """
        self._libudev.udev_monitor_filter_add_match_tag(
            self, ensure_byte_string(tag))
        self._libudev.udev_monitor_filter_update(self) 
开发者ID:mbusb,项目名称:multibootusb,代码行数:24,代码来源:monitor.py

示例2: enable_receiving

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import start [as 别名]
def enable_receiving(self):
        """
        Switch the monitor into listing mode.

        Connect to the event source and receive incoming events.  Only after
        calling this method, the monitor listens for incoming events.

        .. note::

           This method is implicitly called by :meth:`__iter__`.  You don't
           need to call it explicitly, if you are iterating over the
           monitor.

        .. deprecated:: 0.16
           Will be removed in 1.0. Use :meth:`start()` instead.
        """
        import warnings
        warnings.warn('Will be removed in 1.0. Use Monitor.start() instead.',
                      DeprecationWarning)
        self.start() 
开发者ID:mbusb,项目名称:multibootusb,代码行数:22,代码来源:monitor.py

示例3: start

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import start [as 别名]
def start(self):
        """
        Start this monitor.

        The monitor will not receive events until this method is called. This
        method does nothing if called on an already started :class:`Monitor`.

        .. note::

           Typically you don't need to call this method. It is implicitly
           called by :meth:`poll()` and :meth:`__iter__()`.

        .. seealso:: :attr:`started`
        .. versionchanged:: 0.16
           This method does nothing if the :class:`Monitor` was already
           started.
        """
        if not self._started:
            self._libudev.udev_monitor_enable_receiving(self)
            # Force monitor FD into non-blocking mode
            pipe.set_fd_status_flag(self, os.O_NONBLOCK)
            self._started = True 
开发者ID:mbusb,项目名称:multibootusb,代码行数:24,代码来源:monitor.py

示例4: run

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import start [as 别名]
def run(self):
        self.monitor.start()
        notifier = poll.Poll.for_events(
            (self.monitor, 'r'), (self._stop_event.source, 'r'))
        while True:
            for file_descriptor, event in eintr_retry_call(notifier.poll):
                if file_descriptor == self._stop_event.source.fileno():
                    # in case of a stop event, close our pipe side, and
                    # return from the thread
                    self._stop_event.source.close()
                    return
                elif file_descriptor == self.monitor.fileno() and event == 'r':
                    read_device = partial(eintr_retry_call, self.monitor.poll, timeout=0)
                    for device in iter(read_device, None):
                        self._callback(device)
                else:
                    raise EnvironmentError('Observed monitor hung up') 
开发者ID:mbusb,项目名称:multibootusb,代码行数:19,代码来源:monitor.py

示例5: process_packet

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import start [as 别名]
def process_packet(self, ident, code, data, flags):
        """
        Handle packets from VM
        """
        # reply pkt shows only once
        if flags == REPLY_PACKET_TYPE:
            chan = self.reply_pkt_map.get(ident)
            if not chan:
                return
            return chan.put((ident, code, data))
        elif not self.unplug_flag.is_set(): # command packets are buffered
            if code == 0x4064:
                event_kind = struct.unpack(">BIB", data[:6])[2]
                if event_kind in [EVENT_METHOD_ENTRY, EVENT_METHOD_EXIT_WITH_RETURN_VALUE]:
                    self.cmd_pkt_queue.put((ident, code, data))
                elif event_kind == EVENT_BREAKPOINT:
                    Thread(target=self.breakpoint_handler, args=[data]).start()
                elif event_kind == EVENT_CLASS_PREPARE:
                    Thread(target=self.class_prepare_handler, args=[data]).start() 
开发者ID:yzygitzh,项目名称:ReDroid,代码行数:21,代码来源:jdwp.py

示例6: start

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import start [as 别名]
def start(self, join=False):
        """
        when calling with join=True, must call it in main thread, or else, the Keyboard Interrupt won't be caputured.
        :param join: default False, if hold on until the worker is stopped by Ctrl+C or other reasons.
        :return:
        """
        Thread.start(self)

        if join:
            try:
                while self.is_alive():
                    self.join(timeout=60)
                self.logger.info("worker {0} exit unexpected, try to shutdown it".format(self.option.consumer_name))
                self.shutdown()
            except KeyboardInterrupt:
                self.logger.info("*** try to exit **** ")
                self.shutdown() 
开发者ID:aliyun,项目名称:aliyun-log-python-sdk,代码行数:19,代码来源:worker.py

示例7: run

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import start [as 别名]
def run(self):
        self.log(' TaskThread : running ...', prefixname = True)
        while True:
            # If there's not pending task, wait to avoid busy-looping.
            if len(self.tasks) == 0:
                self.wati_for_task.wait()

            # If stop() is called, remaining tasks won't be exectued !
            if self.wati_for_stop.isSet():
                break

            # Remove a pending task from the queue.
            self.__qlock.acquire()
            task = self.tasks.pop(0)
            self.__qlock.release()

            if task:
                self.debug_log(' TaskThread : start executing ... task (%d)'%(task.taskid), prefixname = True)
                task.run()
        self.log(' TaskThread : ending.', prefixname = True) 
开发者ID:PyOCL,项目名称:OpenCLGA,代码行数:22,代码来源:generaltaskthread.py

示例8: started

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import start [as 别名]
def started(self):
        """
        ``True``, if this monitor was started, ``False`` otherwise. Readonly.

        .. seealso:: :meth:`start()`
        .. versionadded:: 0.16
        """
        return self._started 
开发者ID:mbusb,项目名称:multibootusb,代码行数:10,代码来源:monitor.py

示例9: filter_by

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import start [as 别名]
def filter_by(self, subsystem, device_type=None):
        """
        Filter incoming events.

        ``subsystem`` is a byte or unicode string with the name of a
        subsystem (e.g. ``'input'``).  Only events originating from the
        given subsystem pass the filter and are handed to the caller.

        If given, ``device_type`` is a byte or unicode string specifying the
        device type.  Only devices with the given device type are propagated
        to the caller.  If ``device_type`` is not given, no additional
        filter for a specific device type is installed.

        These filters are executed inside the kernel, and client processes
        will usually not be woken up for device, that do not match these
        filters.

        .. versionchanged:: 0.15
           This method can also be after :meth:`start()` now.
        """
        subsystem = ensure_byte_string(subsystem)
        if device_type is not None:
            device_type = ensure_byte_string(device_type)
        self._libudev.udev_monitor_filter_add_match_subsystem_devtype(
            self, subsystem, device_type)
        self._libudev.udev_monitor_filter_update(self) 
开发者ID:mbusb,项目名称:multibootusb,代码行数:28,代码来源:monitor.py

示例10: receive_device

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import start [as 别名]
def receive_device(self):
        """
        Receive a single device from the monitor.

        .. warning::

           You *must* call :meth:`start()` before calling this method.

        The caller must make sure, that there are events available in the
        event queue.  The call blocks, until a device is available.

        If a device was available, return ``(action, device)``.  ``device``
        is the :class:`Device` object describing the device.  ``action`` is
        a string describing the action.  Usual actions are:

        ``'add'``
          A device has been added (e.g. a USB device was plugged in)
        ``'remove'``
          A device has been removed (e.g. a USB device was unplugged)
        ``'change'``
          Something about the device changed (e.g. a device property)
        ``'online'``
          The device is online now
        ``'offline'``
          The device is offline now

        Raise :exc:`~exceptions.EnvironmentError`, if no device could be
        read.

        .. deprecated:: 0.16
           Will be removed in 1.0. Use :meth:`Monitor.poll()` instead.
        """
        import warnings
        warnings.warn('Will be removed in 1.0. Use Monitor.poll() instead.',
                      DeprecationWarning)
        device = self.poll()
        return device.action, device 
开发者ID:mbusb,项目名称:multibootusb,代码行数:39,代码来源:monitor.py

示例11: __iter__

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import start [as 别名]
def __iter__(self):
        """
        Wait for incoming events and receive them upon arrival.

        This methods implicitly calls :meth:`start()`, and starts polling the
        :meth:`fileno` of this monitor.  If a event comes in, it receives the
        corresponding device and yields it to the caller.

        The returned iterator is endless, and continues receiving devices
        without ever stopping.

        Yields ``(action, device)`` (see :meth:`receive_device` for a
        description).

        .. deprecated:: 0.16
           Will be removed in 1.0. Use an explicit loop over :meth:`poll()`
           instead, or monitor asynchronously with :class:`MonitorObserver`.
        """
        import warnings
        warnings.warn('Will be removed in 1.0. Use an explicit loop over '
                      '"poll()" instead, or monitor asynchronously with '
                      '"MonitorObserver".', DeprecationWarning)
        self.start()
        while True:
            device = self.poll()
            if device is not None:
                yield device.action, device 
开发者ID:mbusb,项目名称:multibootusb,代码行数:29,代码来源:monitor.py

示例12: start

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import start [as 别名]
def start(self):
        if self.__useThreading:
            Thread.start(self)
        else:
            self.__preRun() 
开发者ID:sprinkler,项目名称:rainmachine-developer-resources,代码行数:7,代码来源:rmParserThread.py

示例13: createInstance

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import start [as 别名]
def createInstance():
        if RMThreadWatcher.instance is None:
            RMThreadWatcher.instance = RMThreadWatcher()
            RMThreadWatcher.instance.start()
        return RMThreadWatcher.instance.isAlive()

    #----------------------------------------------------------------------------------------
    #
    #
    # 
开发者ID:sprinkler,项目名称:rainmachine-developer-resources,代码行数:12,代码来源:rmThreadWatcher.py

示例14: start

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import start [as 别名]
def start(self):
        if not self.__running:
            self.__running = True
            Thread.start(self) 
开发者ID:sprinkler,项目名称:rainmachine-developer-resources,代码行数:6,代码来源:rmThreadWatcher.py

示例15: createInstance

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import start [as 别名]
def createInstance():
        if RMCommandThread.instance is None:
            RMCommandThread.instance = RMCommandThread()
            RMCommandThread.instance.start()
        return RMCommandThread.instance.isAlive()

    #----------------------------------------------------------------------------------------
    #
    #
    # 
开发者ID:sprinkler,项目名称:rainmachine-developer-resources,代码行数:12,代码来源:rmCommandThread.py


注:本文中的threading.Thread.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。