def __init__(self, port,authkey=None,socket=None,alt_keys={},interval=None,
home=None, proc_name=None, logging=False):
if (not socket) and (type(port) != int or port < 1):
raise Exception('client port must be integer >= 1')
# authkey is used in hmac computation, which doesn't understand unicode
if authkey and type (authkey) != str:
raise Exception('authkey must be a regular string')
Process.__init__(self, self.run, (), logging, proc_name)
self.socket = socket
self.port = port # listening port for all connections
self.fds = {}
if type(authkey) not in [str, types.NoneType]:
raise Exception('authkey must be a regular string or None')
self.keys = {0: authkey} # primary authentication key (may be None)
if alt_keys:
if type(alt_keys) != dict:
raise Exception('alt_keys must be a dictionary')
for k in alt_keys:
if type(alt_keys[k]) not in [str, types.NoneType]:
raise Exception('alt keys must be regular strings or None')
self.keys[k] = alt_keys[k]
if type(interval) not in [int, float, types.NoneType]:
raise Exception(
'the interval (seconds) must be expressed as in integer, a '
'float, or None'
)
if not home:
home = ave.config.load_etc()['home']
self.home = home
self.interval = to_milliseconds(interval)
self.unpend = [] # fd's to ignore in pending events handling
self.rejecting = False
self.accepting = [] # connections
self.authenticating = {} # connection -> salt
self.established = {} # connection -> authkey or None
self.keepwatching = {}
self.listener = None
self.outgoing = {} # connection -> message
self.buf_sizes = (1024*16, 1024*16) # setsockopt() parameters
self.deferred_joins = None
评论列表
文章目录