Il giorno 04/mag/2012, alle ore 08:12, Łukasz Wróblewski ha scritto:
> Hi,
>
> I have two elements:
> A - a script that sends the request to B and waiting for the HTTP response.
> B - uWSGI (without nginx, etc.) waiting for the request, performing
> calculations and sending answer.
>
> All synchronously.
> I use uWSGI 1.2 and Python 3.1.3
>
>
> A:
> """
> from urllib.request import Request, urlopen
> import datetime
>
> def log(s): print('%s\t%s'%(datetime.datetime.now(), s))
>
> req = Request(url='http://127.0.0.1:8000/')
> f = urlopen(req, timeout=220)
> log(f.read().decode())
> """
>
> B:
> """
> import datetime
> import subprocess
>
>
> def log(s): print('%s\t%s'%(datetime.datetime.now(), s))
>
>
>
> def cmd():
> log('cmd start')
> p = subprocess.Popen('vzctl stop 101', shell=True, stdout=subprocess.PIPE,
> stderr=subprocess.PIPE)
> stdout, stderr = p.communicate()
> log(p.returncode)
> log(stdout.decode())
> log(stderr.decode())
> log('cmd done')
> return stdout, stderr, p.returncode
>
>
>
> def application(env, start_response):
> cmd()
> start_response('200 OK', [('Content-Type','text/html; charset=UTF-8')])
> log('res send')
> return b'ok'
>
> """
>
>
> Everything seems to be very simple.
> The problem occurs when I generate IO stress (dd if = / dev / zero ...) on
> the server.
> Then command "vzctl stop 101" returns "timeout !!!", but does not stop its
> operation, takes time of worker. Despite this uWSGI already at this point
> sends an empty response.
> It looks as if vzctl did yield or subprocess.
> log:
>
> 2012-05-04 07:05:03 cmd start
> 2012-05-04 07:05:33 timeout !!! >>> At this point the A has received a blank
> response.
> 2012-05-04 07:06:14 0
> 2012-05-04 07:06:14 ... stdout from vzctl ...
> 2012-05-04 07:06:14
> 2012-05-04 07:06:14 cmd done
> 2012-05-04 07:06:14 res send
>
>
> I tried to reproduce the situation without use vzctl, but I do not know how,
> it makes the print "timeout!" not to stdout and stderr still goes to the log
> uWSGI. "p.communicate()" wait at the end of the command, and uWSGI already
> sent a reply.
>
I have just realized the timeout is coming from the http router. You can
increase it with --http-timeout <n> (where n is the amount of seconds your
subprocess will need to end) or you can disable the router and let uWSGI
workers directly speak HTTP with --http-socket :8000 instead of --http :8000
--
Roberto De Ioris
http://unbit.it
JID: [email protected]
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi