>
> That code didn't work to well and we got some "writev(): Bad file
> descriptor..." errors. Looking at the code I figured that grunt closes the
> parent connection thus not letting it to respond to the client. The
> following code removes this restriction and let the user the ability to
> choose on which process (parent/child) they want to write to back to
> client
> and on the other one they can call uwsgi.disconnect().
>
> diff -ru uwsgi-0.9.7.2/plugins/python/uwsgi_pymodule.c
> uwsgi-0.9.7.2-new/plugins/python/uwsgi_pymodule.c
> --- uwsgi-0.9.7.2/plugins/python/uwsgi_pymodule.c       2011-04-06
> 10:50:01.000000000 +0300
> +++ uwsgi-0.9.7.2-new/plugins/python/uwsgi_pymodule.c   2011-05-22
> 17:23:52.000000000 +0300
> @@ -2182,7 +2182,6 @@
>
>         pid_t grunt_pid;
>         int i;
> -       struct wsgi_request *wsgi_req = current_wsgi_req();
>
>         if (uwsgi.grunt) {
>                 uwsgi_log("spawning a grunt from worker %d (pid
> :%d)...\n",
> uwsgi.mywid, uwsgi.mypid);
> @@ -2218,10 +2217,6 @@
>                 return Py_True;
>         }
>
> -       // close connection on the worker
> -       fclose(wsgi_req->async_post);
> -       wsgi_req->fd_closed = 1;
> -
>        clear:
>         Py_INCREF(Py_None);
>         return Py_None;
>
> I wanted to share this patch and to understand whether it is the right way
> to accomplish what we've been trying to do.
>


As grunt() is heavy used, i would not change its default behaviour.
Check the latest tip, i have added a condition:

if you specify an arg to uwsgi.grunt() the connection will not be closed.

You can now use uwsgi.grunt(True) safely.

As a side note you need to take in account that for every upload you will
generate a new process. This could be a security risk.

I suggest you to use the Spooler for this kind of jobs as it will
serialize tasks (only one process will manages all of the jobs one at
time)


-- 
Roberto De Ioris
http://unbit.it
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to