File tree 1 file changed +6
-8
lines changed
1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -547,23 +547,21 @@ def select(self, timeout=None):
547
547
# If max_ev is 0, kqueue will ignore the timeout. For consistent
548
548
# behavior with the other selector classes, we prevent that here
549
549
# (using max). See https://bugs.python.org/issue29255
550
- max_ev = max ( len (self ._fd_to_key ), 1 )
550
+ max_ev = len (self ._fd_to_key ) or 1
551
551
ready = []
552
552
try :
553
553
kev_list = self ._selector .control (None , max_ev , timeout )
554
554
except InterruptedError :
555
555
return ready
556
+
557
+ fd_to_key = self ._fd_to_key
556
558
for kev in kev_list :
557
559
fd = kev .ident
558
560
flag = kev .filter
559
- events = 0
560
- if flag == select .KQ_FILTER_READ :
561
- events |= EVENT_READ
562
- if flag == select .KQ_FILTER_WRITE :
563
- events |= EVENT_WRITE
564
-
565
- key = self ._fd_to_key .get (fd )
561
+ key = fd_to_key .get (fd )
566
562
if key :
563
+ events = ((flag == select .KQ_FILTER_READ and EVENT_READ )
564
+ | (flag == select .KQ_FILTER_WRITE and EVENT_WRITE ))
567
565
ready .append ((key , events & key .events ))
568
566
return ready
569
567
You can’t perform that action at this time.
0 commit comments