Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, address: str=None, port: int=None,
options: OptionsType =(), sock=None):
if not sock:
if not all((address, port)):
raise RuntimeError(
'You should pass socket instance or '
'"address" and "port" couple'
)
self.socket = bind_socket(
socket.AF_INET6 if ':' in address else socket.AF_INET,
socket.SOCK_DGRAM,
address=address, port=port, options=options,
)
elif not isinstance(sock, socket.socket):
raise ValueError('sock must be socket instance')
else:
self.socket = sock
self.server = None
self._protocol = None
super().__init__()
def __init__(self, *, address: str = None, port: int = None,
cert: PathOrStr, key: PathOrStr, ca: PathOrStr = None,
require_client_cert: bool = False, verify: bool = True,
options: OptionsType = (), sock=None, **kwargs):
self.__ssl_options = cert, key, ca, verify, require_client_cert
if not sock:
if not (address and port):
raise RuntimeError(
'You should pass socket instance or '
'"address" and "port" couple'
)
self.make_socket = partial(
bind_socket,
address=address,
port=port,
options=options,
)
elif not isinstance(sock, socket.socket):
raise ValueError('sock must be socket instance')
else:
self.make_socket = lambda: sock
self.socket = None
super().__init__(**kwargs)
def __init__(self, address: str = None, port: int = None,
options: OptionsType = (), sock=None, **kwargs):
if not sock:
if not (address and port):
raise RuntimeError(
'You should pass socket instance or '
'"address" and "port" couple'
)
self.make_socket = partial(
bind_socket,
socket.AF_INET6 if ':' in address else socket.AF_INET,
socket.SOCK_DGRAM,
address=address, port=port, options=options,
proto_name='udp',
)
elif not isinstance(sock, socket.socket):
raise ValueError('sock must be socket instance')
else:
self.make_socket = lambda: sock
self.server = None
self._protocol = None
self.socket = None
super().__init__(**kwargs)
def __init__(self, address: str=None, port: int=None,
options: OptionsType = (), sock=None):
if not sock:
if not all((address, port)):
raise RuntimeError(
'You should pass socket instance or '
'"address" and "port" couple'
)
self.socket = bind_socket(
address=address, port=port, options=options
)
elif not isinstance(sock, socket.socket):
raise ValueError('sock must be socket instance')
else:
self.socket = sock
super().__init__()
def __init__(self, address: str = 'localhost', port: int = None,
sock: socket.socket = None, shutdown_timeout: int = 5, **kwds):
if not sock:
if not (address and port):
raise RuntimeError(
'You should pass socket instance or '
'"address" and "port" couple'
)
self.socket = bind_socket(
address=address,
port=port,
proto_name='http',
)
elif not isinstance(sock, socket.socket):
raise ValueError('sock must be socket instance')
else:
self.socket = sock
self.runner = None
self.site = None
self.shutdown_timeout = shutdown_timeout
super().__init__(**kwds)
def __init__(self, address: str = None, port: int = None,
options: OptionsType = (), sock=None, **kwargs):
if not sock:
if not (address and port):
raise RuntimeError(
'You should pass socket instance or '
'"address" and "port" couple'
)
self.make_socket = partial(
bind_socket,
address=address,
port=port,
options=options,
)
elif not isinstance(sock, socket.socket):
raise ValueError('sock must be socket instance')
else:
self.make_socket = lambda: sock
self.socket = None
super().__init__(**kwargs)