-Andrew。 It appears that xmlrpclib and/or SimpleXMLRPCServer always use newconnections for each request. I have been trying to make themreuse the existing connection but can''t find where. Is there anyparticular reason they go to such great lengths to call shutdown/close/finishas well as making new connection objects in xmlrpclib?I am actually using M2Crypto so the connection ultimately ends upinside SSL. Having a new connection established for every singlerequest is insane, especially as most of my requests will be lightweight.I expect the clients and servers to be on lower bandwidth connectionsand usually on opposite ends of the US.My attempts so far to make reuse happen have led to a twisty mazeof deep inheritance hierarchies and intertwined transports, connectionsand request handlers hard coding each others classes. No amount ofdebugging and commenting out shutdown/close/finish prevents newconnections from being used.Roger 解决方案multicall is of no use to me because my following requests depend on the resultsof the preceding ones. SSL is really important since the traffic is goingover the open Internet. I needed to do some certificate validation whichthe Python 2.3 library has no facilities for.On the server side, things were hopeless as well. Since it would belistening on the open Internet, and had to work on Windows as well asLinux and Mac, the threading server initially seemed appealing, butsadly it has no facilities for limiting the number of threads spawned.It also makes a new thread per request, rather than the more normaldesign of having a thread pool to deal with requests/connections.xmlrpclib is coded to use the Python 1.5 compatible names (and lack ofHTTP/1.1 and persistent connections). SimpleXMLRPCRequestHandler ishard-coded to close connections after one request (see last line ofdo_POST). The M2Crypto code that added SSL to both inherited thoseimplementations and design.Basically the existing xmlrpclib and SimpleXMLRPCServer are hard coded(and IMHO go out of their way) to do one request per connection, andthen shut things down. Throw in that I needed to do SSL on both ends, withHTTP authentication, and some "light" firewalling in order to preventDOS attacks, I had to spend several days mashing the various classestogether with M2Crypto together.You can see the results here: http://cvs.sf.net/viewcvs.py/bitpim/...py?view=markupRogerGlancing at that, it looks like using Twisted to implement that would be alot easier, and shorter.-Andrew. 这篇关于xmlprclib / server不重用连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-29 14:08
查看更多