You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
python-ldap doesn't appear to retry ldap calls that fail with EINTR.
This is fairly easy to reproduce. If we run a loop doing repeated ldap calls, install a signal handler (that does nothing), and then send the handled signal a few times to the process, it fails almost immediately, raising an exception like ...
It's also fairly easy to fix, since all of the ldap calls seem to happen in ldap.ldapobject.SimpleLDAPObject._ldap_call. If I add a little wrapper like ...
from errno import EINTR
def _retry_if_interrupted(func, *args, **kwargs):
"""
Call func, retrying if it raises an LDAPError with errno == EINTR.
"""
while True:
try:
return func(*args, **kwargs)
except LDAPError as e:
try:
if e.args[0]['errno'] != EINTR:
raise
except (AttributeError, IndexError, KeyError):
raise e
... and change the ldap call to ...
result = _retry_if_interrupted(func, *args, **kwargs)
... then I can no longer reproduce the issue.
We have observed this as the source of sporadic ldap failures in real apps. Requiring callers to do their own EINTR retries seems onerous, and raising exceptions for EINTR "failures" doesn't seem useful, hence the suggestion to retry.
I didn't track down where EINTR originates within OpenLDAP. The OpenLDAP code has many references to EINTR that suggest an intention to retry ... maybe some cases were missed? Retrying by python-ldap seems consistent with that, at least.
Uh oh!
There was an error while loading. Please reload this page.
python-ldap doesn't appear to retry ldap calls that fail with EINTR.
This is fairly easy to reproduce. If we run a loop doing repeated ldap calls, install a signal handler (that does nothing), and then send the handled signal a few times to the process, it fails almost immediately, raising an exception like ...
It's also fairly easy to fix, since all of the ldap calls seem to happen in
ldap.ldapobject.SimpleLDAPObject._ldap_call
. If I add a little wrapper like ...... and change the ldap call to ...
... then I can no longer reproduce the issue.
We have observed this as the source of sporadic ldap failures in real apps. Requiring callers to do their own EINTR retries seems onerous, and raising exceptions for EINTR "failures" doesn't seem useful, hence the suggestion to retry.
I didn't track down where EINTR originates within OpenLDAP. The OpenLDAP code has many references to EINTR that suggest an intention to retry ... maybe some cases were missed? Retrying by python-ldap seems consistent with that, at least.
Operating system: Linux, RHEL 7.5 with kernel-3.10.0-862.11.6.el7.x86_64
Python version: 2.7.15
python-ldap version: 3.1.0
OpenLDAP version: 2.4.39
The text was updated successfully, but these errors were encountered: