Skip to content

Commit

Permalink
add and use SlapdObject._start_sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
stroeder committed Apr 26, 2017
1 parent 447870d commit 9a378ec
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Lib/slapdtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
See http://www.python-ldap.org/ for details.
\$Id: slapdtest.py,v 1.1 2017/04/26 16:52:50 stroeder Exp $
\$Id: slapdtest.py,v 1.2 2017/04/26 20:46:37 stroeder Exp $
Python compability note:
This module only works with Python 2.7.x since
"""

__version__ = '2.4.37'

import os
import socket
import time
Expand Down Expand Up @@ -106,6 +108,9 @@ class SlapdObject(object):
PATH_SLAPD = os.path.join(SBINDIR, 'slapd')
PATH_SLAPTEST = os.path.join(SBINDIR, 'slaptest')

# time in secs to wait before trying to access slapd via LDAP (again)
_start_sleep = 1.5

def __init__(self):
self._proc = None
self._port = find_available_tcp_port(LOCALHOST)
Expand Down Expand Up @@ -183,11 +188,12 @@ def _wait_for_slapd(self):
if self._proc.poll() is not None:
self._stopped()
raise RuntimeError("slapd exited before opening port")
time.sleep(self._start_sleep)
try:
self._log.debug("Connecting to %s", self.ldap_uri)
self.ldapwhoami()
except RuntimeError:
time.sleep(1)
pass
else:
return

Expand Down

0 comments on commit 9a378ec

Please sign in to comment.