Check in the updated version of patch #957240, which doesn't rely

on the marshalling characteristics of infinities.
This commit is contained in:
Michael W. Hudson 2004-06-30 09:02:33 +00:00
parent 96b935e643
commit d5cf143482
2 changed files with 24 additions and 17 deletions

View File

@ -44,20 +44,20 @@ channel (including any that have been added to the map during asynchronous
service) is closed.
\begin{funcdesc}{loop}{\optional{timeout\optional{, use_poll\optional{,
map}}}}
Enter a polling loop that only terminates after all open channels
have been closed. All arguments are optional. The \var{timeout}
argument sets the timeout parameter for the appropriate
\function{select()} or \function{poll()} call, measured in seconds;
the default is 30 seconds. The \var{use_poll} parameter, if true,
indicates that \function{poll()} should be used in preference to
\function{select()} (the default is \code{False}). The \var{map} parameter
is a dictionary whose items are the channels to watch. As channels
are closed they are deleted from their map. If \var{map} is
omitted, a global map is used (this map is updated by the default
class \method{__init__()}
-- make sure you extend, rather than override, \method{__init__()}
if you want to retain this behavior).
map\optional{,count}}}}}
Enter a polling loop that terminates after count passes or all open
channels have been closed. All arguments are optional. The \var(count)
parameter defaults to None, resulting in the loop terminating only
when all channels have been closed. The \var{timeout} argument sets the
timeout parameter for the appropriate \function{select()} or
\function{poll()} call, measured in seconds; the default is 30 seconds.
The \var{use_poll} parameter, if true, indicates that \function{poll()}
should be used in preference to \function{select()} (the default is
\code{False}). The \var{map} parameter is a dictionary whose items are
the channels to watch. As channels are closed they are deleted from their
map. If \var{map} is omitted, a global map is used (this map is updated
by the default class \method{__init__()} -- make sure you extend, rather
than override, \method{__init__()} if you want to retain this behavior).
Channels (instances of \class{asyncore.dispatcher}, \class{asynchat.async_chat}
and subclasses thereof) can freely be mixed in the map.

View File

@ -157,7 +157,7 @@ def poll2(timeout=0.0, map=None):
poll3 = poll2 # Alias for backward compatibility
def loop(timeout=30.0, use_poll=False, map=None):
def loop(timeout=30.0, use_poll=False, map=None, count=None):
if map is None:
map = socket_map
@ -166,8 +166,14 @@ def loop(timeout=30.0, use_poll=False, map=None):
else:
poll_fun = poll
while map:
poll_fun(timeout, map)
if count is None:
while map:
poll_fun(timeout, map)
else:
while map and count > 0:
poll_fun(timeout, map)
count = count - 1
class dispatcher:
@ -523,3 +529,4 @@ if os.name == 'posix':
self._fileno = fd
self.socket = file_wrapper(fd)
self.add_channel()