def _create_name(self) -> str:
"""Creates the name for the handler - called from ``__init__`` if a name is not given.
:returns: a template of `({protocol} )?{host}(:{port})?`
"""
if self.port:
port = ':{}'.format(self.port)
else:
port = ''
if self.family == socket.AF_UNIX:
stype = 'UNIX'
elif self.type == socket.SOCK_STREAM:
stype = 'TCP'
elif self.type == socket.SOCK_DGRAM:
stype = 'UDP'
else:
stype = None # pragma: no cover
if stype:
host = ' {}'.format(self.host)
else:
host = self.host # pragma: no cover
return '{}{}{}'.format(stype, host, port)
评论列表
文章目录