def pg_isready(self) -> PgIsReadyStatus:
        """Runs pg_isready to see if PostgreSQL is accepting connections.

        :returns: one of :class:`PgIsReadyStatus` values."""

        r = self.connection_pool.conn_kwargs
        cmd = [self.pgcommand('pg_isready'), '-p', r['port'], '-d', self._database]

        # Host is not set if we are connecting via default unix socket
        if 'host' in r:
            cmd.extend(['-h', r['host']])

        # We only need the username because pg_isready does not try to authenticate
        if 'user' in r:
            cmd.extend(['-U', r['user']])

        ret = subprocess.call(cmd)
        try:
            return PgIsReadyStatus(ret)
        except ValueError:
            return PgIsReadyStatus.UNKNOWN
Runs pg_isready to see if PostgreSQL is accepting connections.

        :returns: one of :class:`PgIsReadyStatus` values.
patroni/postgresql/__init__.py