Resolve the deferred returned by send_multiResponse and send_multiRes…#239
Resolve the deferred returned by send_multiResponse and send_multiRes…#239spencermaxfield wants to merge 1 commit intotwisted:masterfrom
Conversation
…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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
There was no test covering send_multiResponse_ex when that method was passed a handler.
Resolve the deferred returned by
send_multiResponseandsend_multiResponse_exwhen a handler is provided and the final response has been handled.This makes using
send_multiResponseandsend_multiResponse_exeasier if the caller wants toyielduntil all responses have been handled. With existing behavior where the returned deferred is never fired and you want toyield, you're forced to create and track a separateDeferred, provide it to thehandlerpassed to the calledsend..method, and both fire that deferred and returnTrueafter 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:
docs/source/NEWS.rstCONTRIBUTING.rst.