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
I am running some automated end to end tests with ldaptor client-side.
My code runs a set of LDAP operation and at the end of each test the connection to the LDAP server is closed.
At the end of each test, I have some extra checks that no connections are accidentally left open and that the reactor is clean.
I used to have this final Deferred.addBoth that will forward the result but will close the client connection.
def bb_connect_done(result, client):
"""
Called after all LDAP operations to clean the client.
"""
if client.connected:
client.unbind()
return result
The problem is the client.unbind() is not returning a deferred. Just triggering a transport.loseConnection and hoping for the best :)
This is not a big problem for TCP, but for TLS the TLS shutdown might take a bit longer.
for now, as a workaround I am using this hack ... triggering a disconnection and then calling bind right away to put a request on the wire that will errback when the connection is actually lost.
def bb_connect_done(result, client):
"""
Called after all LDAP operations to clean the client.
"""
if client.connected:
client.unbind()
deferred = client.bind(b'', b'')
deferred.addBoth(lambda _: result)
return deferred
The text was updated successfully, but these errors were encountered:
I am running some automated end to end tests with ldaptor client-side.
My code runs a set of LDAP operation and at the end of each test the connection to the LDAP server is closed.
At the end of each test, I have some extra checks that no connections are accidentally left open and that the reactor is clean.
I used to have this final
Deferred.addBoth
that will forward the result but will close the client connection.The problem is the client.unbind() is not returning a deferred. Just triggering a
transport.loseConnection
and hoping for the best :)This is not a big problem for TCP, but for TLS the TLS shutdown might take a bit longer.
for now, as a workaround I am using this hack ... triggering a disconnection and then calling bind right away to put a request on the wire that will errback when the connection is actually lost.
The text was updated successfully, but these errors were encountered: