> Hello,
>
> I am experimenting wrapping external process stdin and stdout to a web
> service using simple uWSGI.
>
> The demo is like this:
>
>
> def hello_app(environ, start_response):
> start_response('200 OK', [('Content-Type', 'text/plain')])
> proc = subprocess.Popen("echo hello world", shell=True,
> stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
> return environ['wsgi.file_wrapper'](proc.stdout)
>
>
> This works in wsgiref
>
> from wsgiref.simple_server import make_server
> make_server('', 8086, hello_app).serve_forever()
>
>
> But not in uWSGI
>
> uwsgi --http 0:8086 --wsgi bj:hello_app
>
> It returns zero sized http response
>
>
> (and not working in bjeron, too, shows errno 22.)
>
>
>
file_wrapper is an optimization for files (infact it internally calls
sendfile() or something similar). sendfile over pipes does not work.
eventually you can map the stdout of the process to uwsgi.connection_fd()
file descriptor, but it is really ugly.
Even better (and more WSGI friendly) would be buffering the output and
then send it as string/bytes
--
Roberto De Ioris
http://unbit.it
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi