Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python3....
File: selectors.py
super().close()
[500] Fix | Delete
[501] Fix | Delete
[502] Fix | Delete
if hasattr(select, 'kqueue'):
[503] Fix | Delete
[504] Fix | Delete
class KqueueSelector(_BaseSelectorImpl):
[505] Fix | Delete
"""Kqueue-based selector."""
[506] Fix | Delete
[507] Fix | Delete
def __init__(self):
[508] Fix | Delete
super().__init__()
[509] Fix | Delete
self._selector = select.kqueue()
[510] Fix | Delete
[511] Fix | Delete
def fileno(self):
[512] Fix | Delete
return self._selector.fileno()
[513] Fix | Delete
[514] Fix | Delete
def register(self, fileobj, events, data=None):
[515] Fix | Delete
key = super().register(fileobj, events, data)
[516] Fix | Delete
try:
[517] Fix | Delete
if events & EVENT_READ:
[518] Fix | Delete
kev = select.kevent(key.fd, select.KQ_FILTER_READ,
[519] Fix | Delete
select.KQ_EV_ADD)
[520] Fix | Delete
self._selector.control([kev], 0, 0)
[521] Fix | Delete
if events & EVENT_WRITE:
[522] Fix | Delete
kev = select.kevent(key.fd, select.KQ_FILTER_WRITE,
[523] Fix | Delete
select.KQ_EV_ADD)
[524] Fix | Delete
self._selector.control([kev], 0, 0)
[525] Fix | Delete
except:
[526] Fix | Delete
super().unregister(fileobj)
[527] Fix | Delete
raise
[528] Fix | Delete
return key
[529] Fix | Delete
[530] Fix | Delete
def unregister(self, fileobj):
[531] Fix | Delete
key = super().unregister(fileobj)
[532] Fix | Delete
if key.events & EVENT_READ:
[533] Fix | Delete
kev = select.kevent(key.fd, select.KQ_FILTER_READ,
[534] Fix | Delete
select.KQ_EV_DELETE)
[535] Fix | Delete
try:
[536] Fix | Delete
self._selector.control([kev], 0, 0)
[537] Fix | Delete
except OSError:
[538] Fix | Delete
# This can happen if the FD was closed since it
[539] Fix | Delete
# was registered.
[540] Fix | Delete
pass
[541] Fix | Delete
if key.events & EVENT_WRITE:
[542] Fix | Delete
kev = select.kevent(key.fd, select.KQ_FILTER_WRITE,
[543] Fix | Delete
select.KQ_EV_DELETE)
[544] Fix | Delete
try:
[545] Fix | Delete
self._selector.control([kev], 0, 0)
[546] Fix | Delete
except OSError:
[547] Fix | Delete
# See comment above.
[548] Fix | Delete
pass
[549] Fix | Delete
return key
[550] Fix | Delete
[551] Fix | Delete
def select(self, timeout=None):
[552] Fix | Delete
timeout = None if timeout is None else max(timeout, 0)
[553] Fix | Delete
max_ev = len(self._fd_to_key)
[554] Fix | Delete
ready = []
[555] Fix | Delete
try:
[556] Fix | Delete
kev_list = self._selector.control(None, max_ev, timeout)
[557] Fix | Delete
except InterruptedError:
[558] Fix | Delete
return ready
[559] Fix | Delete
for kev in kev_list:
[560] Fix | Delete
fd = kev.ident
[561] Fix | Delete
flag = kev.filter
[562] Fix | Delete
events = 0
[563] Fix | Delete
if flag == select.KQ_FILTER_READ:
[564] Fix | Delete
events |= EVENT_READ
[565] Fix | Delete
if flag == select.KQ_FILTER_WRITE:
[566] Fix | Delete
events |= EVENT_WRITE
[567] Fix | Delete
[568] Fix | Delete
key = self._key_from_fd(fd)
[569] Fix | Delete
if key:
[570] Fix | Delete
ready.append((key, events & key.events))
[571] Fix | Delete
return ready
[572] Fix | Delete
[573] Fix | Delete
def close(self):
[574] Fix | Delete
self._selector.close()
[575] Fix | Delete
super().close()
[576] Fix | Delete
[577] Fix | Delete
[578] Fix | Delete
# Choose the best implementation, roughly:
[579] Fix | Delete
# epoll|kqueue|devpoll > poll > select.
[580] Fix | Delete
# select() also can't accept a FD > FD_SETSIZE (usually around 1024)
[581] Fix | Delete
if 'KqueueSelector' in globals():
[582] Fix | Delete
DefaultSelector = KqueueSelector
[583] Fix | Delete
elif 'EpollSelector' in globals():
[584] Fix | Delete
DefaultSelector = EpollSelector
[585] Fix | Delete
elif 'DevpollSelector' in globals():
[586] Fix | Delete
DefaultSelector = DevpollSelector
[587] Fix | Delete
elif 'PollSelector' in globals():
[588] Fix | Delete
DefaultSelector = PollSelector
[589] Fix | Delete
else:
[590] Fix | Delete
DefaultSelector = SelectSelector
[591] Fix | Delete
[592] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function