[Checkins] SVN: zc.monitor/trunk/src/zc/monitor/__init__.py overloaded start, parameter can be:

Adam Groszer agroszer at gmail.com
Sun Jan 24 07:33:36 EST 2010


Log message for revision 108431:
  overloaded start, parameter can be:
  - int:port
  - tuple:(address, port)
  - string:unix domain socket
  tests needed....

Changed:
  U   zc.monitor/trunk/src/zc/monitor/__init__.py

-=-
Modified: zc.monitor/trunk/src/zc/monitor/__init__.py
===================================================================
--- zc.monitor/trunk/src/zc/monitor/__init__.py	2010-01-24 12:25:53 UTC (rev 108430)
+++ zc.monitor/trunk/src/zc/monitor/__init__.py	2010-01-24 12:33:35 UTC (rev 108431)
@@ -70,15 +70,27 @@
         pass                            # Don't care
 
 
-def start(port, address=''):
+def start(address):
     """start monitor server.
 
     Returns True if monitor server started; returns False if the port is
     already in use; and raises an exception otherwise.
     """
     import zc.ngi.async
+
+    ourAddress = None
+    if isinstance(address, int):
+        #a port is passed as int
+        ourAddress = ('', address)
+    elif isinstance(address, tuple):
+        #an (address, port) tuple is passed
+        ourAddress = address
+    elif isinstance(address, basestring):
+        #a unix domain socket string is passed
+        ourAddress = address
+
     try:
-        zc.ngi.async.listener((address, port), Server)
+        zc.ngi.async.listener(ourAddress, Server)
     except socket.error, e:
         if e.args[0] == errno.EADDRINUSE:
             # Don't kill the process just because somebody else has our port.



More information about the checkins mailing list