@@ -745,8 +745,7 @@ def _upgrade_broker(broker):
745745 broker .timers = TimerList ()
746746 LOG .debug ('upgraded %r with %r (new: %d readers, %d writers; '
747747 'old: %d readers, %d writers)' , old , new ,
748- len (new .readers ), len (new .writers ),
749- len (old .readers ), len (old .writers ))
748+ len (new ._rfds ), len (new ._wfds ), len (old ._rfds ), len (old ._wfds ))
750749
751750
752751@mitogen .core .takes_econtext
@@ -902,22 +901,18 @@ def __repr__(self):
902901class PollPoller (mitogen .core .Poller ):
903902 """
904903 Poller based on the POSIX :linux:man2:`poll` interface. Not available on
905- some versions of OS X, otherwise it is the preferred poller for small FD
906- counts, as there is no setup/teardown/configuration system call overhead.
904+ some Python/OS X combinations. Otherwise the preferred poller for small
905+ FD counts; or if many pollers are created, used once, then closed.
906+ There there is no setup/teardown/configuration system call overhead.
907907 """
908908 SUPPORTED = hasattr (select , 'poll' )
909- _repr = 'PollPoller()'
909+ _readmask = SUPPORTED and select . POLLIN | select . POLLHUP
910910
911911 def __init__ (self ):
912912 super (PollPoller , self ).__init__ ()
913913 self ._pollobj = select .poll ()
914914
915915 # TODO: no proof we dont need writemask too
916- _readmask = (
917- getattr (select , 'POLLIN' , 0 ) |
918- getattr (select , 'POLLHUP' , 0 )
919- )
920-
921916 def _update (self , fd ):
922917 mask = (((fd in self ._rfds ) and self ._readmask ) |
923918 ((fd in self ._wfds ) and select .POLLOUT ))
@@ -952,7 +947,6 @@ class KqueuePoller(mitogen.core.Poller):
952947 Poller based on the FreeBSD/Darwin :freebsd:man2:`kqueue` interface.
953948 """
954949 SUPPORTED = hasattr (select , 'kqueue' )
955- _repr = 'KqueuePoller()'
956950
957951 def __init__ (self ):
958952 super (KqueuePoller , self ).__init__ ()
@@ -1030,7 +1024,7 @@ class EpollPoller(mitogen.core.Poller):
10301024 Poller based on the Linux :linux:man7:`epoll` interface.
10311025 """
10321026 SUPPORTED = hasattr (select , 'epoll' )
1033- _repr = 'EpollPoller()'
1027+ _inmask = SUPPORTED and select . EPOLLIN | select . EPOLLHUP
10341028
10351029 def __init__ (self ):
10361030 super (EpollPoller , self ).__init__ ()
@@ -1077,9 +1071,6 @@ def stop_transmit(self, fd):
10771071 self ._wfds .pop (fd , None )
10781072 self ._control (fd )
10791073
1080- _inmask = (getattr (select , 'EPOLLIN' , 0 ) |
1081- getattr (select , 'EPOLLHUP' , 0 ))
1082-
10831074 def _poll (self , timeout ):
10841075 the_timeout = - 1
10851076 if timeout is not None :
@@ -1100,18 +1091,14 @@ def _poll(self, timeout):
11001091 yield data
11011092
11021093
1103- # 2.4 and 2.5 only had select.select() and select.poll().
1104- for _klass in mitogen .core .Poller , PollPoller , KqueuePoller , EpollPoller :
1105- if _klass .SUPPORTED :
1106- PREFERRED_POLLER = _klass
1094+ POLLERS = (EpollPoller , KqueuePoller , PollPoller , mitogen .core .Poller )
1095+ PREFERRED_POLLER = next (cls for cls in POLLERS if cls .SUPPORTED )
1096+
11071097
11081098# For processes that start many threads or connections, it's possible Latch
11091099# will also get high-numbered FDs, and so select() becomes useless there too.
1110- # So swap in our favourite poller.
1111- if PollPoller .SUPPORTED :
1112- mitogen .core .Latch .poller_class = PollPoller
1113- else :
1114- mitogen .core .Latch .poller_class = PREFERRED_POLLER
1100+ POLLER_LIGHTWEIGHT = PollPoller .SUPPORTED and PollPoller or PREFERRED_POLLER
1101+ mitogen .core .Latch .poller_class = POLLER_LIGHTWEIGHT
11151102
11161103
11171104class LineLoggingProtocolMixin (object ):
0 commit comments