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


Python select.EPOLLPRI属性代码示例

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


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

示例1: _poll_queue_event

# 需要导入模块: import select [as 别名]
# 或者: from select import EPOLLPRI [as 别名]
def _poll_queue_event(self, events):
        """
        EPoll event callback
        """

        for fd, event in events:
            if not (event & (select.EPOLLPRI | select.EPOLLET)):
                continue

            try:
                values = self._allocated_pins.itervalues()
            except AttributeError:
                values = self._allocated_pins.values()
            for pin in values:
                if pin.fileno() == fd:
                    pin.changed(pin.read()) 
开发者ID:derekstavis,项目名称:python-sysfs-gpio,代码行数:18,代码来源:gpio.py

示例2: _run

# 需要导入模块: import select [as 别名]
# 或者: from select import EPOLLPRI [as 别名]
def _run(self):

        while self._running:
            events = self._poll.poll(EPOLL_TIMEOUT)
            for fd, event in events:
                if not (event & (select.EPOLLPRI | select.EPOLLET)):
                    continue

                self.changed(self.read()) 
开发者ID:respeaker,项目名称:respeaker_python_library,代码行数:11,代码来源:gpio.py

示例3: _getflags

# 需要导入模块: import select [as 别名]
# 或者: from select import EPOLLPRI [as 别名]
def _getflags(self, aiobj):
        flags = 0
        if aiobj.readable():
            flags = EPOLLIN
        if aiobj.writable():
            flags |= EPOLLOUT
        if aiobj.priority():
            flags |= EPOLLPRI
        return flags

    # A poller is itself selectable so may be nested in another Poll
    # instance. Therefore, supports the async interface itself. 
开发者ID:kdart,项目名称:pycopia,代码行数:14,代码来源:asyncio.py

示例4: _poll_queue_register_pin

# 需要导入模块: import select [as 别名]
# 或者: from select import EPOLLPRI [as 别名]
def _poll_queue_register_pin(self, pin):
        ''' Pin responds to fileno(), so it's pollable. '''
        self._poll_queue.register(pin, (select.EPOLLPRI | select.EPOLLET)) 
开发者ID:derekstavis,项目名称:python-sysfs-gpio,代码行数:5,代码来源:gpio.py

示例5: run

# 需要导入模块: import select [as 别名]
# 或者: from select import EPOLLPRI [as 别名]
def run(self):
        """
        Main event loop
        """
        # Create dict of Event File Descriptor: Event File Object
        event_file_map = {event_file.fileno(): event_file for event_file in self.open_event_files}

        # Create epoll object
        poll_object = select.epoll()

        # Register files with select
        for event_fd in event_file_map.keys():
            poll_object.register(event_fd, select.EPOLLIN | select.EPOLLPRI)

        # Loop
        while not self._shutdown:
            # epoll is nice but it wasn't getting events properly :(

            try:  # Cheap hack until i merged new code
                if self._use_epoll:
                    self._poll_epoll(poll_object, event_file_map)
                else:
                    self._poll_read()
            except (IOError, OSError):  # Basically if there's an error, most likely device has been removed then it'll get deleted properly
                pass

            time.sleep(SPIN_SLEEP)

        # Unbind files and close them
        for event_fd, event_file in event_file_map.items():
            poll_object.unregister(event_fd)
            event_file.close()

        poll_object.close() 
开发者ID:openrazer,项目名称:openrazer,代码行数:36,代码来源:key_event_management.py

示例6: __init__

# 需要导入模块: import select [as 别名]
# 或者: from select import EPOLLPRI [as 别名]
def __init__(self, number, direction=INPUT, callback=None, edge=None, active_low=0):
        """
        @type  number: int
        @param number: The pin number
        @type  direction: int
        @param direction: Pin direction, enumerated by C{Direction}
        @type  callback: callable
        @param callback: Method be called when pin changes state
        @type  edge: int
        @param edge: The edge transition that triggers callback,
                     enumerated by C{Edge}
        @type active_low: int
        @param active_low: Indicator of whether this pin uses inverted
                           logic for HIGH-LOW transitions.
        """
        self._number = number
        self._direction = direction
        self._callback = callback
        self._active_low = active_low

        if not os.path.isfile(self._sysfs_gpio_value_path()):
            with open(SYSFS_EXPORT_PATH, 'w') as export:
                export.write('%d' % number)
        else:
            Logger.debug("SysfsGPIO: Pin %d already exported" % number)

        self._fd = open(self._sysfs_gpio_value_path(), 'r+')

        if callback and not edge:
            raise Exception('You must supply a edge to trigger callback on')

        with open(self._sysfs_gpio_direction_path(), 'w') as fsdir:
            fsdir.write(direction)

        if edge:
            with open(self._sysfs_gpio_edge_path(), 'w') as fsedge:
                fsedge.write(edge)
                self._poll = select.epoll()
                self._poll.register(self, (select.EPOLLPRI | select.EPOLLET))
                self.thread = Thread(target=self._run)
                self.thread.daemon = True
                self._running = True
                self.thread.start()

        if active_low:
            if active_low not in ACTIVE_LOW_MODES:
                raise Exception('You must supply a value for active_low which is either 0 or 1.')
            with open(self._sysfs_gpio_active_low_path(), 'w') as fsactive_low:
                fsactive_low.write(str(active_low)) 
开发者ID:respeaker,项目名称:respeaker_python_library,代码行数:51,代码来源:gpio.py

示例7: poll

# 需要导入模块: import select [as 别名]
# 或者: from select import EPOLLPRI [as 别名]
def poll(self, timeout=-1.0):
        while 1:
            try:
                rl = self.pollster.poll(timeout)
            except IOError as why:
                if why.errno == EINTR:
                    self._run_idle()
                    continue
                else:
                    raise
            else:
                break
        for fd, flags in rl:
            try:
                hobj = self.smap[fd]
            except KeyError: # this should never happen, but let's be safe.
                continue
            if hobj is None: # signals simple callback
                self._fd_callbacks[fd]()
                continue
            try:
                if (flags & EPOLLERR):
                    hobj.error_handler()
                    continue
                if (flags & POLLNVAL):
                    self.unregister_fd(fd)
                    continue
                if (flags & EPOLLPRI):
                    hobj.pri_handler()
                if (flags & EPOLLIN):
                    hobj.read_handler()
                if (flags & EPOLLOUT):
                    hobj.write_handler()
                if (flags & EPOLLHUP):
                    hobj.hangup_handler()
            except UnregisterNow as unr:
                self.unregister(unr.obj)
            except UnregisterFDNow as unr:
                self.unregister_fd(unr.filedescriptor)
            except (KeyboardInterrupt, SystemExit):
                raise
            except:
                ex, val, tb = sys.exc_info()
                hobj.exception_handler(ex, val, tb) 
开发者ID:kdart,项目名称:pycopia,代码行数:46,代码来源:asyncio.py


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