本文整理汇总了Python中socketserver.ThreadingTCPServer.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python ThreadingTCPServer.__init__方法的具体用法?Python ThreadingTCPServer.__init__怎么用?Python ThreadingTCPServer.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类socketserver.ThreadingTCPServer
的用法示例。
在下文中一共展示了ThreadingTCPServer.__init__方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from socketserver import ThreadingTCPServer [as 别名]
# 或者: from socketserver.ThreadingTCPServer import __init__ [as 别名]
def __init__(self, host='localhost', port=DEFAULT_LOGGING_CONFIG_PORT,
handler=None):
ThreadingTCPServer.__init__(self, (host, port), handler)
logging._acquireLock()
self.abort = 0
logging._releaseLock()
self.timeout = 1
示例2: __init__
# 需要导入模块: from socketserver import ThreadingTCPServer [as 别名]
# 或者: from socketserver.ThreadingTCPServer import __init__ [as 别名]
def __init__(self, host="", port=COBRA_PORT, sslcrt=None, sslkey=None, sslca=None, msgpack=False, json=False):
'''
Construct a cobra daemon object.
Parameters:
host - Optional hostname/ip to bind the service to (default: inaddr_any)
port - The port to bind (Default: COBRA_PORT)
msgpack - Use msgpack serialization
# SSL Options
sslcrt / sslkey - Specify sslcrt and sslkey to enable SSL server side
sslca - Specify an SSL CA key to use validating client certs
'''
self.thr = None
self.run = True
self.shared = {}
self.dowith = {}
self.host = host
self.port = port
self.reflock = RLock()
self.refcnts = {}
self.authmod = None
self.sflags = 0
if msgpack and json:
raise Exception('CobraDaemon can not use both msgpack *and* json!')
if msgpack:
requireMsgpack()
self.sflags |= SFLAG_MSGPACK
if json:
self.sflags |= SFLAG_JSON
# SSL Options
self.sslca = sslca
self.sslcrt = sslcrt
self.sslkey = sslkey
self.cansetattr = True
self.cangetattr = True
if sslcrt and not os.path.isfile(sslcrt):
raise Exception('CobraDaemon: sslcrt param must be a file!')
if sslkey and not os.path.isfile(sslkey):
raise Exception('CobraDaemon: sslkey param must be a file!')
if sslca and not os.path.isfile(sslca):
raise Exception('CobraDaemon: sslca param must be a file!')
self.allow_reuse_address = True
ThreadingTCPServer.__init__(self, (host, port), CobraRequestHandler)
if port == 0:
self.port = self.socket.getsockname()[1]
self.daemon_threads = True
self.recvtimeout = None
示例3: __init__
# 需要导入模块: from socketserver import ThreadingTCPServer [as 别名]
# 或者: from socketserver.ThreadingTCPServer import __init__ [as 别名]
def __init__(self, host='localhost',
port=logging.handlers.DEFAULT_TCP_LOGGING_PORT,
handler=LogRecordStreamHandler):
ThreadingTCPServer.__init__(self, (host, port), handler)
self.abort = False
self.timeout = 0.1
self.finished = threading.Event()
示例4: __init__
# 需要导入模块: from socketserver import ThreadingTCPServer [as 别名]
# 或者: from socketserver.ThreadingTCPServer import __init__ [as 别名]
def __init__(self, host="", port=COBRA_PORT, sslcrt=None, sslkey=None, sslca=None, sess_timeout=24, attr=True):
'''
Construct a cobra daemon object.
Parameters:
host - Optional hostname/ip to bind the service to (default: inaddr_any)
port - The port to bind (Default: COBRA_PORT)
timeout - The length any session can last, before forcing reconnect
attr - Toggle to turn off the ability to set or get attributes
# SSL Options
sslcrt / sslkey - Specify sslcrt and sslkey to enable SSL server side
sslca - Specify an SSL CA key to use validating client certs
'''
self.shared = {}
self.host = host
self.port = port
self.reflock = RLock()
self.refcnts = {}
self.authmod = None
self.attr = attr
self.sessions = {} # authenticated sessions
self.sess_timeout=sess_timeout*60
# SSL Options
self.sslca = sslca
self.sslcrt = sslcrt
self.sslkey = sslkey
if sslcrt and not os.path.isfile(sslcrt):
raise Exception('CobraDaemon: sslcrt param must be a file!')
if sslkey and not os.path.isfile(sslkey):
raise Exception('CobraDaemon: sslkey param must be a file!')
if sslca and not os.path.isfile(sslca):
raise Exception('CobraDaemon: sslca param must be a file!')
#ThreadingTCPServer.__init__(self, (host, port), CobraHttpConnectionHandler)
ThreadingTCPServer.__init__(self, (host, port), CobraHttpRequestHandler)
t = Thread(target=self._timeoutSessions)
t.setDaemon(1)
t.start()
if port == 0:
self.port = self.socket.getsockname()[1]
self.daemon_threads = True
self.recvtimeout = None
示例5: __init__
# 需要导入模块: from socketserver import ThreadingTCPServer [as 别名]
# 或者: from socketserver.ThreadingTCPServer import __init__ [as 别名]
def __init__(self, config, handler_class):
server_address = (config['server']['ip'], config['server']['port'],)
# Bind and activate server in I{activate} method
ThreadingTCPServer.__init__(self, server_address, handler_class, 0)
Daemon.__init__(self, config['server']['pid'])
# Signals not catched in serve_forever, we need to execute serve_forever
# again because signals are raised exception in I{main} method
self.__by_signal_do = 0
self.__local_sock = None
self.allow_reuse_address = 1
self._config = config.copy()
self._aliases = {}
self.timeout = config['server']['timeout']
示例6: run
# 需要导入模块: from socketserver import ThreadingTCPServer [as 别名]
# 或者: from socketserver.ThreadingTCPServer import __init__ [as 别名]
def run(self):
ThreadingTCPServer.__init__(self, (self.host, self.port), self.handler)
self.abort = 0
self.timeout = 1
self.logname = None
import select
abort = 0
while not abort:
rd, wr, ex = select.select([self.socket.fileno()],
[], [],
self.timeout)
if rd:
self.handle_request()
abort = self.abort
示例7: __init__
# 需要导入模块: from socketserver import ThreadingTCPServer [as 别名]
# 或者: from socketserver.ThreadingTCPServer import __init__ [as 别名]
def __init__(self, addr, handler, timeout=1):
ThreadingTCPServer.__init__(self, addr, LogRecordStreamHandler)
BaseServer.__init__(self, handler, timeout)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
示例8: __init__
# 需要导入模块: from socketserver import ThreadingTCPServer [as 别名]
# 或者: from socketserver.ThreadingTCPServer import __init__ [as 别名]
def __init__(self, addr, handler, timeout=1):
ThreadingTCPServer.__init__(self, addr, LogRecordStreamHandler)
BaseServer.__init__(self, handler, timeout)
示例9: __init__
# 需要导入模块: from socketserver import ThreadingTCPServer [as 别名]
# 或者: from socketserver.ThreadingTCPServer import __init__ [as 别名]
def __init__(self,listen,prefix):
self.allow_reuse_address=True
ThreadingTCPServer.__init__(self,listen, TCPCauldronRequestHandler)
CauldronServer.__init__(self, prefix)
示例10: __init__
# 需要导入模块: from socketserver import ThreadingTCPServer [as 别名]
# 或者: from socketserver.ThreadingTCPServer import __init__ [as 别名]
def __init__(
self, host=LOG_SERVER_HOST, port=LOG_SERVER_PORT,
handler=LogRecordStreamHandler):
ThreadingTCPServer.__init__(self, (host, port), handler)
self.abort = 0
self.timeout = 1
示例11: __init__
# 需要导入模块: from socketserver import ThreadingTCPServer [as 别名]
# 或者: from socketserver.ThreadingTCPServer import __init__ [as 别名]
def __init__(self,http_address,binding):
self.http_address = http_address
ThreadingTCPServer.__init__(self,binding,SocksHandler)
示例12: __init__
# 需要导入模块: from socketserver import ThreadingTCPServer [as 别名]
# 或者: from socketserver.ThreadingTCPServer import __init__ [as 别名]
def __init__(self, proxy, target, server_address):
self.proxy = ParentProxy('', proxy)
self.target = target
self.addr = server_address
logger.info('starting tcp forward from %s(local) to %s(remote) via %s' % (server_address, target, self.proxy))
ThreadingTCPServer.__init__(self, server_address, tcp_tunnel_handler)