[Twisted-Python] Request.getClient

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Wed Jul 2 10:26:28 MDT 2014


Hello all,

twisted.web.http.Request.getClient has a terrible implementation.  It 
does blocking network I/O (DNS).  Fortunately it is only used in one 
place in Twisted - the CGI implementation.  Unfortunately this makes the 
CGI implementation somewhat unsuited for real-world use.

`Request.getClient` has always been allowed to return `None` under 
certain circumstances.  I propose making it always return `None` and 
deprecating it.

This is implemented in the branch linked to <https://tm.tl/2252>.

Chris Armstrong suggested that this change might not be strictly keeping 
with our backwards compatibility policy.

I suggest that either it is - because `None` was always a possible 
return value - or that removing the possibility of blocking I/O from 
applications that are mistakenly using this API makes it worth the not- 
strictly-compatible change.

A minor adjustment might be to make it always return the IP address 
instead, as this was another behavior it previously had.

Please comment.  Thanks.

Jean-Paul



More information about the Twisted-Python mailing list