On Feb 9, 1:05 am, Graham Dumpleton <[email protected]>
wrote:
> 2009/2/9 gert <[email protected]>:
>
> > when i comment out wsgi.file it works
>
> > from os import path
> >        f=open(path.join(path.dirname(__file__),'../bin/
> > picture.png'),'rb')
> >        # if 'wsgi.file_wrapper' in environ: return environ
> > ['wsgi.file_wrapper'](f, 8192)
> >        # else:
> >        return iter(lambda: f.read(8192), '')
>
> Use the test script from genro's post on February 4th in discussion:
>
>  http://groups.google.com/group/modwsgi/browse_frm/thread/69d3076689a4...
>
> In particular:
>
> def application(environ, start_response):
>     size=environ.get('QUERY_STRING')
>     if size=='': size='255'
>     size=int(size)
>     file=open('tmp/wsgitest','wb')
>     for i in range(size):
>         file.write('*')
>     file.close()
>     file=open('tmp/wsgitest','rb')
>     file_wrapper = environ.get('wsgi.file_wrapper', None)
>     start_response('200 OK',[])
>     return file_wrapper(file, 4096*16)
>
> See if you find similar results where whether it works depends on file size.
>
> It is interesting that genro sees a difference at 256, as that is a
> key value in Apache for which below it doesn't try and use sendfile.
>
>   #define AP_MIN_SENDFILE_BYTES           (256)
>
> Another interesting constant in Apache is:
>
>   #define AP_MIN_BYTES_TO_WRITE  8000
>
> Which is close to the other end of the range where they see a problem.
>
> I haven't myself yet had a chance since getting back home yesterday to
> try that test script.
>
> PS. When replying, please do not discard the previous posts of the
> discussion so context isn't lost.
> And before you complain the script doesn't work, fix the obvious of
> adding '/' at front of paths so uses /tmp, rather than 'tmp' directory
> of what ever current working directory of Apache may be.

http://91.121.53.159/test.wsgi?0 = OK
http://91.121.53.159/test.wsgi?1 = OK
...
http://91.121.53.159/test.wsgi?255 = OK
http://91.121.53.159/test.wsgi?256 = (9)Bad file descriptor:
core_output_filter: writing data to the network

py3k mod wsgi trunk apache 2.2.11

def application(environ, start_response):
    size=environ.get('QUERY_STRING')
    if size=='': size='255'
    size=int(size)
    file=open('/tmp/wsgitest','wb')
    for i in range(size):
        file.write(b'*')   # <- Could have been me complaining :P
    file.close()
    file=open('/tmp/wsgitest','rb')
    file_wrapper = environ.get('wsgi.file_wrapper', None)
    start_response('200 OK',[])
    return file_wrapper(file, 4096*16)

I swear if my hd is full i know it will be one of you flapsjaks on
this list :)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to