Skip to content

Conversation

@spencermaxfield
Copy link

Resolve the deferred returned by send_multiResponse and send_multiResponse_ex when a handler is provided and the final response has been handled.

This makes using send_multiResponse and send_multiResponse_ex easier if the caller wants to yield until all responses have been handled. With existing behavior where the returned deferred is never fired and you want to yield, you're forced to create and track a separate Deferred, provide it to the handler passed to the called send.. method, and both fire that deferred and return True after the last response is handled.

This change will not affect any existing callers of the methods prior behavior was that the returned deferred did nothing

Contributor Checklist:

  • I have updated the release notes at docs/source/NEWS.rst
  • I have updated the automated tests.
  • All tests pass on your local dev environment. See CONTRIBUTING.rst.

…ponse_ex when a handler is provided and the final response has been handled

- Dropped support for Python 3.5
- The Deferred returned from send_multiResponse and send_multiResponse_ex is
now fired after the final response is handled.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open to suggestions on better wording here. I wasn't sure how to say this differently without getting too technical for release notes.

If `handler` is not provided, the Deferred returned by this
function will fire with the final LDAP response.
function will fire with the first LDAP response.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment was wrong, as is evidenced by the updated test_send_multiResponse_with_handler test

del self.onwire[msg.id]
else:
if handler(msg.value, *args, **kwargs):
d.callback(None)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functional changes are these two d.callback lines. This lets callers of send_multiResponse and send_multiResponse_ex yield on those methods if they want to yield until all responses have been handled.

resp_bytestring = response.toWire()
client.dataReceived(resp_bytestring)
self.assertEqual(response.value, results[0])
self.assertFalse(d.called)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making sure the deferred is not fired until the multi-response handler returns True

client.dataReceived(resp_bytestring)
self.assertEqual((response.value, response.controls), self.successResultOf(d))

def test_send_multiResponse_ex_with_handler(self):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was no test covering send_multiResponse_ex when that method was passed a handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant