Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Ticket #837 (defect)

Opened 6 months ago

Last modified 2 months ago

Make CP_fileobject specific to the Python version running the WSGI server

Status: closed (fixed)

Reported by: lawouach Assigned to: fumanchu
Priority: normal Milestone: 3.2
Component: wsgiserver Keywords:
Cc: carlos@pemas.es

CherryPy wsgi server subclasses socket._fileobject which has changed its internal read buffer from Python 2.6 (with a possibility of backporting to Python 2.5).

Implement CP_fileobject to support the new buffering type (StringIO) and ensure we match the Python version when running the server.

Source: http://groups.google.com/group/cherrypy-users/browse_thread/thread/1f1352a13ed42f6

Attachments

access.log (41.8 kB) - added by guest on 07/08/08 12:04:25.
error.log (1.0 kB) - added by guest on 07/08/08 12:05:21.
testsuite_output.log (10.6 kB) - added by guest on 07/08/08 12:06:00.
diff (4.4 kB) - added by guest on 07/08/08 12:10:27.
updated.diff (15.8 kB) - added by nusgnaf@gmail.com on 07/09/08 11:02:05.
837.patch (21.2 kB) - added by lawouach on 07/26/08 14:49:38.
Fix for #837
837.2049.patch (21.1 kB) - added by dowski on 10/24/08 23:25:06.
python 2.5.2 support and bugfix (no calls to buffer(...))

Change History

07/08/08 12:04:25: Modified by guest

  • attachment access.log added.

07/08/08 12:05:21: Modified by guest

  • attachment error.log added.

07/08/08 12:06:00: Modified by guest

  • attachment testsuite_output.log added.

07/08/08 12:07:51: Modified by nusgnaf@gmail.com

To reproduce the problem, I checkout python trunk code, and install cherrypy againtst it.

Python 2.6b1+ (trunk:64757, Jul 6 2008, 23:16:51)

I noticed CP_fileobject subclass socket._fileobject , and some methods are mostly identical, so I simplay delete following instance method of CP_fileobject: flush, read, readline. The Good: simple things work. The Bad: I run testsuite, three fails. Please see attachment for further detail.

07/08/08 12:10:27: Modified by guest

  • attachment diff added.

07/08/08 12:16:02: Modified by lawouach

Well it seems it would make little sense for CP to inherit _fileobject if you were not redefining its methods. For instance that class doesn't call directly self._sock.* method but wraps them into its own methods to trap some errors.

07/08/08 13:30:06: Modified by nusgnaf@gmail.com

Thanks for clarifying this. It helps me understanding server code better. So as the upstream change will be available in 2.6+, and from the diff http://svn.python.org/view?rev=62627&view=rev it's strictly _fileobject change, maybe we should import upstream code.

07/09/08 11:01:28: Modified by nusgnaf@gmail.com

Reference original code, I mainly import socket._fileobject from latest python trunk, add appropriate error handling code. python 2.3, 2.4,2.5 all pass the test suite. Python 2.6 still see some compatibility issue, all related with trunked response, I believe that belongs another ticket.

Please review updated.diff.

07/09/08 11:02:05: Modified by nusgnaf@gmail.com

  • attachment updated.diff added.

07/26/08 14:49:38: Modified by lawouach

  • attachment 837.patch added.

Fix for #837

07/26/08 14:49:57: Modified by lawouach

Attached is a patch that would solved the issue against Python 2.6b2. I've also updated a few tests accordingly. I've checked and the full test suite passed on Python 2.5.2 and Python 2.6b2. I couldn't try with other versions (notably older ones).

10/01/08 08:28:51: Modified by nicoe@no-log.org

Hi Sylvain,

I think that in the test checking for version 2.6 you forgot to add an 'or' clause for version 2.5.2 because without this clause I still can't use cherrypy with python 2.5.2

10/24/08 22:54:42: Modified by dowski

Lawouach - Thanks for doing the initial work on this. I took up the huge task (wink, wink) of adding in a clause for Python 2.5.2.

Is there anything in here preventing us from committing this to trunk? I'm guessing that SSL is still an issue, but I don't have the proper libs installed to test it at this point. Should the lack of SSL support keep it out of trunk though?

10/24/08 23:06:37: Modified by dowski

Hmm, nvmd - I am seeing sporadic issues just serving a simple test app. I guess it needs further investigation.

10/24/08 23:25:06: Modified by dowski

  • attachment 837.2049.patch added.

python 2.5.2 support and bugfix (no calls to buffer(...))

10/24/08 23:26:41: Modified by dowski

Ok, sporadic issues appear to be gone. Looked like the original 837.patch was making calls to some buffer callable that wasn't actually present in the wsgiserver. Odd that all the unittests still passed ...

10/24/08 23:35:58: Modified by dowski

Meh, still getting strange responses ... here is an example response body:

TTP/1.1 408 Request TimeoutContent-Length: 0
Content-Type: text/plain

Needed: sleep and tests, I suppose.

10/30/08 09:15:21: Modified by dowski

Well duh. The 408 wasn't entirely cherrypy's fault. I was proxying to CP with Apache 2. Apparently the 408s are a known issue (cf http://groups.google.com/group/cherrypy-users/browse_thread/thread/e751976da1d01390 and #853).

11/01/08 05:06:34: Modified by

  • cc set to carlos@pemas.es.

11/08/08 15:18:33: Modified by fumanchu

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in trunk in [2063], [2069], and [2070]. Backported to 3.1.x in [2071].

Hosted by WebFaction

Log in as guest/cpguest to create tickets