[Checkins] SVN: zc.ngi/trunk/ - Fixed bad logging of ``listening on ...``. The message was emitted
Adam Groszer
agroszer at gmail.com
Sun Jan 24 08:19:13 EST 2010
Log message for revision 108433:
- Fixed bad logging of ``listening on ...``. The message was emitted
before the actual operation was successful.
Emits now a warning ``unable to listen on...`` if binding to the given
address fails.
Changed:
U zc.ngi/trunk/README.txt
U zc.ngi/trunk/src/zc/ngi/async.py
U zc.ngi/trunk/src/zc/ngi/async.txt
-=-
Modified: zc.ngi/trunk/README.txt
===================================================================
--- zc.ngi/trunk/README.txt 2010-01-24 12:52:19 UTC (rev 108432)
+++ zc.ngi/trunk/README.txt 2010-01-24 13:19:12 UTC (rev 108433)
@@ -25,6 +25,11 @@
- Fixed bad logging of ``listening on ...`` for ``listener``
and ``udp_listener``.
+- Fixed bad logging of ``listening on ...``. The messge was emitted
+ before the actual operation was successful.
+ Emits now a warning ``unable to listen on...`` if binding to the given
+ address fails.
+
==================
1.1.5 (2010-01-19)
==================
Modified: zc.ngi/trunk/src/zc/ngi/async.py
===================================================================
--- zc.ngi/trunk/src/zc/ngi/async.py 2010-01-24 12:52:19 UTC (rev 108432)
+++ zc.ngi/trunk/src/zc/ngi/async.py 2010-01-24 13:19:12 UTC (rev 108433)
@@ -368,11 +368,12 @@
try:
if not is_win32:
self.set_reuse_addr()
+ self.bind(addr)
self.logger.info("listening on %r", addr)
- self.bind(addr)
self.listen(255)
except socket.error:
self.close()
+ self.logger.warn("unable to listen on %r", addr)
raise
self.add_channel(_map)
notify_select()
@@ -441,10 +442,11 @@
self.create_socket(family, socket.SOCK_DGRAM)
if not is_win32:
self.set_reuse_addr()
+ self.bind(addr)
self.logger.info("listening on udp %r", addr)
- self.bind(addr)
except socket.error:
self.close()
+ self.logger.warn("unable to listen on udp %r", addr)
raise
self.add_channel(_map)
notify_select()
Modified: zc.ngi/trunk/src/zc/ngi/async.txt
===================================================================
--- zc.ngi/trunk/src/zc/ngi/async.txt 2010-01-24 12:52:19 UTC (rev 108432)
+++ zc.ngi/trunk/src/zc/ngi/async.txt 2010-01-24 13:19:12 UTC (rev 108433)
@@ -215,3 +215,27 @@
>>> listener.close()
>>> time.sleep(0.1)
+
+
+Trying to rebind to a port in use:
+
+ >>> loghandler.clear()
+
+ >>> listener = zc.ngi.async.listener(('127.0.0.1', 9645), handler)
+ >>> time.sleep(0.1)
+
+ >>> listener2 = zc.ngi.async.listener(('127.0.0.1', 9645), handler)
+ Traceback (most recent call last):
+ ...
+ error: (98, 'Address already in use')
+ >>> time.sleep(0.1)
+
+ >>> logcontent = str(loghandler)
+ >>> print logcontent # doctest: +ELLIPSIS
+ zc.ngi.async.server INFO
+ listening on ('127.0.0.1', 9645)
+ zc.ngi.async.server WARNING
+ unable to listen on ('127.0.0.1', 9645)
+
+ >>> listener.close()
+ >>> time.sleep(0.1)
More information about the checkins
mailing list