Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Commit

Permalink
overloaded start, parameter can be:
Browse files Browse the repository at this point in the history
- int:port
- tuple:(address, port)
- string:unix domain socket
tests needed....
  • Loading branch information
Adam Groszer committed Jan 24, 2010
1 parent ce845b4 commit a6cd9ff
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/zc/monitor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,27 @@ def handle_close(self, connection, reason):
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.
Expand Down

0 comments on commit a6cd9ff

Please sign in to comment.