def bind_unix_listener(self):
# http://0pointer.de/blog/projects/systemd.html (search "file
# descriptor 3")
try:
socket_fd = 3
self.sock = socket.fromfd(socket_fd, socket.AF_UNIX,
socket.SOCK_STREAM)
self.sock.listen(50)
return self.sock
except (TypeError, BlockingIOError, socket.error, ValueError):
pass
try:
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
if os.path.exists(MESSAGE_SOCK_PATH):
os.remove(MESSAGE_SOCK_PATH)
self.sock.bind(MESSAGE_SOCK_PATH)
self.sock.listen(50)
return self.sock
except Exception as ex:
exc_type, exc_value, exc_tb = sys.exc_info()
traceback.print_exception(exc_type, exc_value, exc_tb,
file=sys.stderr)
raise ex
评论列表
文章目录