<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _poll_slapd(self, timeout=DEFAULT_STARTUP_DELAY):
 """Poll slapd port until available."""


        begin = time.time()
        time.sleep(0.5)
        while time.time() < begin + timeout:
            if self._process.poll() is not None:
                raise RuntimeError("LDAP server has exited before starting listen.")

            s = socket.socket()
            try:
                s.connect(('localhost', self.port))
            except socket.error:
                # Not ready yet, sleep
                time.sleep(0.5)
            else:
                return
            finally:
                s.close()

        raise RuntimeError("LDAP server not responding within %s seconds." % timeout)