当前位置: 首页>>代码示例>>Python>>正文


Python ThreadingTCPServer.__init__方法代码示例

本文整理汇总了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
开发者ID:LinkedModernismProject,项目名称:web_code,代码行数:9,代码来源:config.py

示例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
开发者ID:bat-serjo,项目名称:vivisect,代码行数:62,代码来源:__init__.py

示例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()
开发者ID:LinkedModernismProject,项目名称:web_code,代码行数:9,代码来源:test_logging.py

示例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
开发者ID:bat-serjo,项目名称:vivisect,代码行数:55,代码来源:http.py

示例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']
开发者ID:warstranger,项目名称:Simple-File-Server,代码行数:16,代码来源:sfserver.py

示例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
开发者ID:rayosborn,项目名称:nxpeaks,代码行数:18,代码来源:nxlogger.py

示例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)
开发者ID:awsch,项目名称:lantz,代码行数:6,代码来源:log.py

示例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)
开发者ID:D3f0,项目名称:prymatex,代码行数:5,代码来源:listeners.py

示例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)
开发者ID:zbyufei,项目名称:ExtreMon,代码行数:6,代码来源:tcp_cauldron_server.py

示例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
开发者ID:ftkghost,项目名称:supersaver,代码行数:8,代码来源:logserver.py

示例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)
开发者ID:Andrepuel,项目名称:HttpTunnel,代码行数:5,代码来源:Client.py

示例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)
开发者ID:dalian3164,项目名称:fwlite,代码行数:8,代码来源:tcp_tunnel.py


注:本文中的socketserver.ThreadingTCPServer.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。