本文整理匯總了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