wsgi.file_wrapper implementation is buggy

1 view
Skip to first unread message

yzhang

unread,
Apr 12, 2008, 7:59:01 AM4/12/08
to cogen
Hi ionel.mc,

When I use your wsgi server (0.1.7) to serve static files, i found it
buggy. The traceback output:

************************************************************
Traceback (most recent call last):
File "/home/yzhang/staffoo/pycodes/cogen/web/wsgi.py", line 438, in
run
blocksize=response.blocksize )#, timeout=-1)
File "/home/yzhang/staffoo/pycodes/cogen/core/reactors.py", line 81,
in run_operation
r = op.try_run(reactor)
File "/home/yzhang/staffoo/pycodes/cogen/core/sockets.py", line 165,
in try_run
result = self.run(reactor)
File "/home/yzhang/staffoo/pycodes/cogen/core/sockets.py", line 278,
in run
assert self.sent <= self.length
AssertionError
************************************************************

BR.
- yzhang

Ionel Maries Cristian

unread,
Apr 12, 2008, 8:06:13 AM4/12/08
to co...@googlegroups.com
I think that has been fixed in trunk (also in trunk file_wrapper checks the content-length and adds the chunked content encoding padding).
Can you check out the trunk and check again ? (easy_install cogen==dev)

Yong Zhang

unread,
Apr 16, 2008, 3:39:47 AM4/16/08
to co...@googlegroups.com
The trunk version still have some little bug, such as:

************************************************************
Traceback (most recent call last):
  File "/home/yzhang/staffoo/pycodes/cogen/web/wsgi.py", line 453, in run
    fsize = fstat(response.filelike.fileno()).st_size
NameError: global name 'fstat' is not defined
************************************************************


After modified the line 453 to "fsize = os.fstat(response.filelike.fileno()).st_size", it works.
 
I do not do any stress testing yet, only do a just-work testing.
 
BR.
-yzhang

Maries Ionel Cristian

unread,
Apr 16, 2008, 5:26:16 PM4/16/08
to cogen
I've added some unittest for the filewrapper and fixed some other
related bugs in the trunk.
Also, i've fixed that AssertionError (seems it wasn't completely
gone).
file_wrapper/SendFileoperation should be reliable now.

On Apr 16, 10:39 am, "Yong Zhang" <yzhang.shang...@gmail.com> wrote:
> The trunk version still have some little bug, such as:
>
> ************************************************************
>
> > Traceback (most recent call last):
> >   File "/home/yzhang/staffoo/pycodes/cogen/web/wsgi.py", line 453, in run
> >     fsize = fstat(response.filelike.fileno()).st_size
> > NameError: global name 'fstat' is not defined
> > ************************************************************
>
> After modified the line 453 to "*fsize = os.
> fstat(response.filelike.fileno()).st_size*", it works.
>
> I do not do any stress testing yet, only do a just-work testing.
>
> BR.
> -yzhang
> On Sat, Apr 12, 2008 at 8:06 PM, Ionel Maries Cristian <ionel...@gmail.com>
> wrote:
>
> > I think that has been fixed in trunk (also in trunk file_wrapper checks
> > the content-length and adds the chunked content encoding padding).
> > Can you check out the trunk and check again ? (easy_install cogen==dev)
>

Yong Zhang

unread,
Apr 19, 2008, 1:48:58 AM4/19/08
to co...@googlegroups.com
It works. now.

Yong Zhang

unread,
Apr 24, 2008, 5:40:56 PM4/24/08
to co...@googlegroups.com
It is still unstable now, sometimes (not always). But, it is difficult to describle the symptom: the web browser can not get the static file, just display loading ...

-yzhang

Ionel Maries Cristian

unread,
Apr 25, 2008, 1:21:56 AM4/25/08
to co...@googlegroups.com
what reactor are you using? is it the latest version from trunk?
--
http://ionelmc.wordpress.com

Ionel Maries Cristian

unread,
Apr 25, 2008, 9:30:32 AM4/25/08
to co...@googlegroups.com
Ah, looks like there really was a problem: when the app was only yielding empty chunks (that means only using the async wsgi extensions) the response wasn't started - thus hanging the client.
If that was your problem it's fixed now in trunk - also, i've added a testcase for it so it won't happen again.

Also, you could trigger this problem if you where returning the file_wrapper and not calling start_response first (i added a assertion for this case too).

Though I would like to hear more details from you.
--
http://ionelmc.wordpress.com

Yong Zhang

unread,
Apr 26, 2008, 12:00:19 PM4/26/08
to co...@googlegroups.com
Thanks. I will try the new updates later.

2008/4/25 Ionel Maries Cristian <ione...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages