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


Python select.POLLPRI属性代码示例

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


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

示例1: pollmask_to_str

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLPRI [as 别名]
def pollmask_to_str(mask):
        """
        Conver pool mast to string

        :param mask: poll return mask
        """
        out = ""
        if (mask & select.POLLIN):
            out += "IN "
        if (mask & select.POLLPRI):
            out += "PRI IN "
        if (mask & select.POLLOUT):
            out += "OUT "
        if (mask & select.POLLERR):
            out += "ERR "
        if (mask & select.POLLHUP):
            out += "HUP "
        if (mask & select.POLLMSG):
            out += "MSG "
        return out 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:22,代码来源:virtio_console_guest.py

示例2: poll

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLPRI [as 别名]
def poll(self, timeout=None):
        if not isinstance(timeout, (int, float, type(None))):
            raise TypeError("Invalid timeout type, should be integer, float, or None.")

        # Setup poll
        p = select.poll()
        p.register(self._line_fd, select.POLLIN | select.POLLPRI | select.POLLERR)

        # Scale timeout to milliseconds
        if isinstance(timeout, (int, float)) and timeout > 0:
            timeout *= 1000

        # Poll
        events = p.poll(timeout)

        return len(events) > 0 
开发者ID:vsergeev,项目名称:python-periphery,代码行数:18,代码来源:gpio.py

示例3: poll

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLPRI [as 别名]
def poll(self, timeout=None):
        """Poll for data available for reading from the serial port with an
        optional timeout.

        `timeout` can be positive for a timeout in seconds, zero for a
        non-blocking poll, or negative or None for a blocking poll. Default is
        a blocking poll.

        Args:
            timeout (int, float, None): timeout duration in seconds.

        Returns:
            bool: ``True`` if data is available for reading from the serial port, ``False`` if not.

        """
        p = select.poll()
        p.register(self._fd, select.POLLIN | select.POLLPRI)
        events = p.poll(int(timeout * 1000))

        if len(events) > 0:
            return True

        return False 
开发者ID:vsergeev,项目名称:python-periphery,代码行数:25,代码来源:serial.py

示例4: poll

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLPRI [as 别名]
def poll(self):
        r, w, x = select.select(self.readable(), self.writable(), self.exceptional())

        events = {} 
        self.collate_events(r, select.POLLIN, events)
        self.collate_events(w, select.POLLOUT, events)
        self.collate_events(x, select.POLLPRI, events)

        final_events = []
        for fd in events:
            mask = 0

            for event in events[fd]:
                mask |= event

            final_events.append([ fd, mask ])

        return final_events 
开发者ID:pycepa,项目名称:pycepa,代码行数:20,代码来源:Select.py

示例5: readwrite

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLPRI [as 别名]
def readwrite(obj, flags):
    try:
        if flags & select.POLLIN:
            obj.handle_read_event()
        if flags & select.POLLOUT:
            obj.handle_write_event()
        if flags & select.POLLPRI:
            obj.handle_expt_event()
        if flags & (select.POLLHUP | select.POLLERR | select.POLLNVAL):
            obj.handle_close()
    except OSError as e:
        if e.args[0] not in _DISCONNECTED:
            obj.handle_error()
        else:
            obj.handle_close()
    except _reraised_exceptions:
        raise
    except:
        obj.handle_error() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:21,代码来源:asyncore.py

示例6: poll2

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLPRI [as 别名]
def poll2(timeout=0.0, map=None):
    # Use the poll() support added to the select module in Python 2.0
    if map is None:
        map = socket_map
    if timeout is not None:
        # timeout is in milliseconds
        timeout = int(timeout*1000)
    pollster = select.poll()
    if map:
        for fd, obj in list(map.items()):
            flags = 0
            if obj.readable():
                flags |= select.POLLIN | select.POLLPRI
            # accepting sockets should not be writable
            if obj.writable() and not obj.accepting:
                flags |= select.POLLOUT
            if flags:
                pollster.register(fd, flags)

        r = pollster.poll(timeout)
        for fd, flags in r:
            obj = map.get(fd)
            if obj is None:
                continue
            readwrite(obj, flags) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:27,代码来源:asyncore.py

示例7: poll

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLPRI [as 别名]
def poll(self, timeout = None):
            events = self._poll.poll(timeout)
            processed = []
            for fd, evt in events:
                mask = ""
                if evt & (select_module.POLLIN | select_module.POLLPRI):
                    mask += "r"
                if evt & select_module.POLLOUT:
                    mask += "w"
                if evt & select_module.POLLERR:
                    mask += "e"
                if evt & select_module.POLLHUP:
                    mask += "h"
                if evt & select_module.POLLNVAL:
                    mask += "n"
                processed.append((fd, mask))
            return processed 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:19,代码来源:compat.py

示例8: poll

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLPRI [as 别名]
def poll(self, timeout):
            if timeout is not None:
                # convert from seconds to milliseconds
                timeout *= 1000
            changes = self._poll.poll(timeout)
            results = []
            for fd, events in changes:
                f = self._get_file_object(fd)
                if events & (select.POLLIN | select.POLLPRI):
                    results.append((f, POLLER_EVENT_READ))
                elif events & (select.POLLOUT):
                    results.append((f, POLLER_EVENT_WRITE))
                elif events & (select.POLLHUP):
                    results.append((f, POLLER_EVENT_HUP))
                elif events & (select.POLLERR | select.POLLNVAL):
                    results.append((f, POLLER_EVENT_ERROR))
            return results 
开发者ID:acaceres2176,项目名称:scylla,代码行数:19,代码来源:sh.py

示例9: __init__

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLPRI [as 别名]
def __init__(self, termfd, endpoint, obj):
        """
        \param termfd is a file descriptor on which to select() to
        wait for termination requests from the main CallPipe_Callee
        thread
        \param Endpoint is an endpoint of a bidirectional multiprocessing.Pipe
        \param obj is the object on which to perform the method calls
        """
        threading.Thread.__init__(self)
        self.__endpoint = endpoint
        self.__obj      = obj
        self.__waitset  = select.poll()
        eventmask = select.POLLIN | select.POLLERR \
                    | select.POLLHUP | select.POLLPRI
        self.__waitset.register(self.__endpoint.fileno(), eventmask)
        self.__waitset.register(termfd, eventmask) 
开发者ID:ActiveState,项目名称:code,代码行数:18,代码来源:recipe-576509.py

示例10: __init__

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLPRI [as 别名]
def __init__(self, *args, **kwargs):
        result = super(self.__class__, self).__init__(*args, **kwargs)

        # Setting O_NONBLOCK on stdin, strout, stderr
        fcntl.fcntl(self.stdin, fcntl.F_SETFL, fcntl.fcntl(self.stdin, fcntl.F_GETFL) | os.O_NONBLOCK)
        fcntl.fcntl(self.stdout, fcntl.F_SETFL, fcntl.fcntl(self.stdout, fcntl.F_GETFL) | os.O_NONBLOCK)
        fcntl.fcntl(self.stderr, fcntl.F_SETFL, fcntl.fcntl(self.stderr, fcntl.F_GETFL) | os.O_NONBLOCK)
        
        # Using poll to get file status
        self.poller = Poll() # My own class with len()
        self.poller.register(self.stdin, select.POLLOUT | select.POLLERR | select.POLLHUP)
        self.poller.register(self.stdout, select.POLLIN | select.POLLPRI | select.POLLERR | select.POLLHUP)
        self.poller.register(self.stderr, select.POLLIN | select.POLLPRI | select.POLLERR | select.POLLHUP)

        return result

    #def __del__(self, *args, **kwargs):
        #super(self.__class__, self).__del__()
        #map(self.poller.unregister, (self.stdin, self.stdout, self.stderr)) 
开发者ID:ValdikSS,项目名称:distvidc,代码行数:21,代码来源:nbsubprocess.py

示例11: main

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLPRI [as 别名]
def main(args, controller=None):
    import select
    if controller is None:
        controller = Controller("Controller")
    fds = {}
    poll = select.poll()
    for dev in args:
        type, dev = dev.split(":",1)
        dev = HIDevice(controller, dev, type)
        fds[dev.fileno()] = dev
        poll.register(dev, select.POLLIN | select.POLLPRI)
    while True:
        for x,e in poll.poll():
            dev = fds[x]
            dev.read() 
开发者ID:KanoComputing,项目名称:kano-toolset,代码行数:17,代码来源:pyinputevent.py

示例12: readwrite

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLPRI [as 别名]
def readwrite(obj, flags):
    try:
        if flags & select.POLLIN:
            obj.handle_read_event()
        if flags & select.POLLOUT:
            obj.handle_write_event()
        if flags & select.POLLPRI:
            obj.handle_expt_event()
        if flags & (select.POLLHUP | select.POLLERR | select.POLLNVAL):
            obj.handle_close()
    except socket.error, e:
        if e.args[0] not in _DISCONNECTED:
            obj.handle_error()
        else:
            obj.handle_close() 
开发者ID:glmcdona,项目名称:meddle,代码行数:17,代码来源:asyncore.py

示例13: poll2

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLPRI [as 别名]
def poll2(timeout=0.0, map=None):
    # Use the poll() support added to the select module in Python 2.0
    if map is None:
        map = socket_map
    if timeout is not None:
        # timeout is in milliseconds
        timeout = int(timeout*1000)
    pollster = select.poll()
    if map:
        for fd, obj in map.items():
            flags = 0
            if obj.readable():
                flags |= select.POLLIN | select.POLLPRI
            if obj.writable():
                flags |= select.POLLOUT
            if flags:
                # Only check for exceptions if object was either readable
                # or writable.
                flags |= select.POLLERR | select.POLLHUP | select.POLLNVAL
                pollster.register(fd, flags)
        try:
            r = pollster.poll(timeout)
        except select.error, err:
            if err.args[0] != EINTR:
                raise
            r = []
        for fd, flags in r:
            obj = map.get(fd)
            if obj is None:
                continue
            readwrite(obj, flags) 
开发者ID:glmcdona,项目名称:meddle,代码行数:33,代码来源:asyncore.py

示例14: poll2

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLPRI [as 别名]
def poll2(timeout=0.0, map=None):
    # Use the poll() support added to the select module in Python 2.0
    if map is None:
        map = socket_map
    if timeout is not None:
        # timeout is in milliseconds
        timeout = int(timeout*1000)
    pollster = select.poll()
    if map:
        for fd, obj in map.items():
            flags = 0
            if obj.readable():
                flags |= select.POLLIN | select.POLLPRI
            # accepting sockets should not be writable
            if obj.writable() and not obj.accepting:
                flags |= select.POLLOUT
            if flags:
                # Only check for exceptions if object was either readable
                # or writable.
                flags |= select.POLLERR | select.POLLHUP | select.POLLNVAL
                pollster.register(fd, flags)
        try:
            r = pollster.poll(timeout)
        except select.error, err:
            if err.args[0] != EINTR:
                raise
            r = []
        for fd, flags in r:
            obj = map.get(fd)
            if obj is None:
                continue
            readwrite(obj, flags) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:34,代码来源:asyncore.py

示例15: poll_ignore_interrupts

# 需要导入模块: import select [as 别名]
# 或者: from select import POLLPRI [as 别名]
def poll_ignore_interrupts(fds, timeout=None):
    '''Simple wrapper around poll to register file descriptors and
    ignore signals.'''

    if timeout is not None:
        end_time = time.time() + timeout

    poller = select.poll()
    for fd in fds:
        poller.register(fd, select.POLLIN | select.POLLPRI | select.POLLHUP | select.POLLERR)

    while True:
        try:
            timeout_ms = None if timeout is None else timeout * 1000
            results = poller.poll(timeout_ms)
            return [afd for afd, _ in results]
        except InterruptedError:
            err = sys.exc_info()[1]
            if err.args[0] == errno.EINTR:
                # if we loop back we have to subtract the
                # amount of time we already waited.
                if timeout is not None:
                    timeout = end_time - time.time()
                    if timeout < 0:
                        return []
            else:
                # something else caused the select.error, so
                # this actually is an exception.
                raise 
开发者ID:pypa,项目名称:pipenv,代码行数:31,代码来源:utils.py


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