本文整理汇总了Python中SocketServer.BaseServer.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python BaseServer.__init__方法的具体用法?Python BaseServer.__init__怎么用?Python BaseServer.__init__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SocketServer.BaseServer
的用法示例。
在下文中一共展示了BaseServer.__init__方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from SocketServer import BaseServer [as 别名]
# 或者: from SocketServer.BaseServer import __init__ [as 别名]
def __init__(self, cmd = None, env_term = None):
# Set Linux signal handler
uname = commands.getoutput('uname')
if uname == 'Linux':
self.sigchldhandler = signal.signal(signal.SIGCHLD, signal.SIG_IGN)
# Session
self.session = {}
self.cmd = cmd
self.env_term = env_term
# Synchronize methods
self.lock = threading.RLock()
for name in ['proc_keepalive', 'proc_buryall',
'proc_read', 'proc_write', 'proc_dump', 'proc_getalive']:
orig = getattr(self, name)
setattr(self, name, SynchronizedMethod(self.lock, orig))
# Supervisor thread
self.signal_stop = 0
self.thread = threading.Thread(target = self.proc_thread)
self.thread.start()
示例2: __init__
# 需要导入模块: from SocketServer import BaseServer [as 别名]
# 或者: from SocketServer.BaseServer import __init__ [as 别名]
def __init__(self, server_address, handler_class, config,
bind_and_activate=True):
# pylint: disable=super-init-not-called, non-parent-init-called
# Init just BaseServer, TCPServer creates a socket.
BaseServer.__init__(self, server_address, handler_class)
if isinstance(server_address, socket.socket):
# It's a bound and activates socket from systemd.
self.socket = server_address
bind_and_activate = False
else:
self.socket = socket.socket(self.address_family,
self.socket_type)
# copied from TCPServer
if bind_and_activate:
try:
self.server_bind()
self.server_activate()
except BaseException:
self.server_close()
raise
if self.socket.family == socket.AF_UNIX:
self.socket_file = self.socket.getsockname()
if 'consumers' not in config:
raise ValueError('Configuration does not provide any consumer')
self.config = config
if 'server_string' in self.config:
self.server_string = self.config['server_string']
self.auditlog = log.auditlog
示例3: __init__
# 需要导入模块: from SocketServer import BaseServer [as 别名]
# 或者: from SocketServer.BaseServer import __init__ [as 别名]
def __init__(self, server_address, RequestHandlerClass):
BaseServer.__init__(self, server_address, RequestHandlerClass)
self.server_bind()
示例4: __init__
# 需要导入模块: from SocketServer import BaseServer [as 别名]
# 或者: from SocketServer.BaseServer import __init__ [as 别名]
def __init__(self, server_address, RequestHandlerClass):
from OpenSSL import SSL
BaseServer.__init__(self, server_address, RequestHandlerClass)
ctx = SSL.Context(SSL.SSLv3_METHOD)
cert = os.path.join(settings.Config.ResponderPATH, settings.Config.SSLCert)
key = os.path.join(settings.Config.ResponderPATH, settings.Config.SSLKey)
ctx.use_privatekey_file(key)
ctx.use_certificate_file(cert)
self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))
self.server_bind()
self.server_activate()