本文整理汇总了Python中select.KQ_EV_ADD属性的典型用法代码示例。如果您正苦于以下问题:Python select.KQ_EV_ADD属性的具体用法?Python select.KQ_EV_ADD怎么用?Python select.KQ_EV_ADD使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类select
的用法示例。
在下文中一共展示了select.KQ_EV_ADD属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register
# 需要导入模块: import select [as 别名]
# 或者: from select import KQ_EV_ADD [as 别名]
def register(self, fileobj, events, data=None):
key = super(KqueueSelector, self).register(fileobj, events, data)
if events & EVENT_READ:
kevent = select.kevent(key.fd,
select.KQ_FILTER_READ,
select.KQ_EV_ADD)
_syscall_wrapper(self._kqueue.control, False, [kevent], 0, 0)
if events & EVENT_WRITE:
kevent = select.kevent(key.fd,
select.KQ_FILTER_WRITE,
select.KQ_EV_ADD)
_syscall_wrapper(self._kqueue.control, False, [kevent], 0, 0)
return key
示例2: test_issue30058
# 需要导入模块: import select [as 别名]
# 或者: from select import KQ_EV_ADD [as 别名]
def test_issue30058(self):
# changelist must be an iterable
kq = select.kqueue()
a, b = socket.socketpair()
ev = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE)
kq.control([ev], 0)
# not a list
kq.control((ev,), 0)
# __len__ is not consistent with __iter__
class BadList:
def __len__(self):
return 0
def __iter__(self):
for i in range(100):
yield ev
kq.control(BadList(), 0)
# doesn't have __len__
kq.control(iter([ev]), 0)
a.close()
b.close()
kq.close()
示例3: registerForEvents
# 需要导入模块: import select [as 别名]
# 或者: from select import KQ_EV_ADD [as 别名]
def registerForEvents(self, asyncSocket, readEvents, writeEvents):
fileno = asyncSocket.fileno()
if readEvents:
readKE = select.kevent(ident = fileno,
filter = select.KQ_FILTER_READ,
flags = select.KQ_EV_ADD)
else:
readKE = select.kevent(ident = fileno,
filter = select.KQ_FILTER_READ,
flags = (select.KQ_EV_ADD | select.KQ_EV_DISABLE))
if writeEvents:
writeKE = select.kevent(ident = fileno,
filter = select.KQ_FILTER_WRITE,
flags = select.KQ_EV_ADD)
else:
writeKE = select.kevent(ident = fileno,
filter = select.KQ_FILTER_WRITE,
flags = (select.KQ_EV_ADD | select.KQ_EV_DISABLE))
# Should be able to put readKE and writeKE in a list in
# one call to kqueue.control, but this is broken due to Python issue 5910
self.__kqueue.control([readKE], 0, 0)
self.__kqueue.control([writeKE], 0, 0)
示例4: register
# 需要导入模块: import select [as 别名]
# 或者: from select import KQ_EV_ADD [as 别名]
def register(self, fd, events):
if fd in self._active:
raise IOError("fd %s already registered" % fd)
self._control(fd, events, select.KQ_EV_ADD)
self._active[fd] = events
示例5: register
# 需要导入模块: import select [as 别名]
# 或者: from select import KQ_EV_ADD [as 别名]
def register(self, fileobj, events, data=None):
key = super(KqueueSelector, self).register(fileobj, events, data)
if events & EVENT_READ:
kev = select.kevent(key.fd, select.KQ_FILTER_READ,
select.KQ_EV_ADD)
self._kqueue.control([kev], 0, 0)
if events & EVENT_WRITE:
kev = select.kevent(key.fd, select.KQ_FILTER_WRITE,
select.KQ_EV_ADD)
self._kqueue.control([kev], 0, 0)
return key