[IMP] gunicorn: changed print with logging.info.

bzr revid: vmt@openerp.com-20120120160409-cu1vcw7cfa3z0zgy
This commit is contained in:
Vo Minh Thu
2012-01-20 17:04:09 +01:00
parent 5e2721aaf2
commit 30d7253fef
3 changed files with 5 additions and 12 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ pidfile = '.gunicorn.pid'
# Gunicorn recommends 2-4 x number_of_cpu_cores, but
# you'll want to vary this a bit to find the best for your
# particular work load.
workers = 1
workers = 4
# Some application-wide initialization is needed.
on_starting = openerp.wsgi.on_starting
@@ -20,7 +20,6 @@ class m(openerp.osv.osv.Model):
if not hasattr(self, 'l'):
self.l = []
self.l.append([0] * size)
print ">>>", len(self.l)
return True
def consume_time(self, cr, uid, seconds, context=None):
@@ -31,13 +30,9 @@ class m(openerp.osv.osv.Model):
import os
t0 = time.clock()
t1 = time.clock()
# try:
while t1 - t0 < seconds:
print "[%s] ..." % os.getpid()
for i in xrange(10000000):
x = i * i
t1 = time.clock()
# except Exception, e:
# print "+++", e
return True
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+4 -6
View File
@@ -490,7 +490,6 @@ def pre_request(worker, req):
# VMS and RLIMIT_AS are the same thing: virtual memory, a.k.a. address space
rss, vms = psutil.Process(os.getpid()).get_memory_info()
soft, hard = resource.getrlimit(resource.RLIMIT_AS)
print ">>>>>> [%s] %s %s %s %s %s" % (os.getpid(), vms, req.method, req.path, req.query, req.fragment)
resource.setrlimit(resource.RLIMIT_AS, (config['virtual_memory_limit'], hard))
r = resource.getrusage(resource.RUSAGE_SELF)
@@ -505,7 +504,8 @@ def post_request(worker, req, environ):
import psutil
rss, vms = psutil.Process(os.getpid()).get_memory_info()
if vms > config['virtual_memory_reset']:
print ">>> Worker eating too much memory, reset it after the request."
logging.getLogger('wsgi.worker').info('Virtual memory consumption '
'too high, rebooting the worker.')
worker.alive = False # Commit suicide after the request.
# Our signal handler will signal a SGIQUIT to all workers.
@@ -516,10 +516,8 @@ def make_winch_handler(server):
# SIGXCPU (exceeded CPU time) signal handler will raise an exception.
def time_expired(n, stack):
import os
import time
print '>>> [%s] time ran out.' % (os.getpid())
raise Exception('(time ran out)') # TODO one of openerp.exception
logging.getLogger('wsgi.worker').info('CPU time limit exceeded.')
raise Exception('CPU time limit exceeded.') # TODO one of openerp.exception
# Kill gracefuly the workers (e.g. because we want to clear their cache).
# This is done by signaling a SIGWINCH to the master process, so it can be