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.
--
Łukasz Wróblewski
http://www.nri.pl/ - Nowoczesne Rozwiązania Internetowe
http://www.hostowisko.pl/ - Profesjonalny i tani hosting
http://www.katalog-polskich-firm.pl/ - Najlepszy darmowy katalog firm
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi