summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVo Minh Thu <vmt@openerp.com>2012-01-20 17:04:09 +0100
committerVo Minh Thu <vmt@openerp.com>2012-01-20 17:04:09 +0100
commit30d7253fef235bbb117aeec0a27c7c5e3c436c4a (patch)
treead5f4b813504c1417760760a562fdaaeffe6f238
parent5e2721aaf247a75f8361f1272617b2cf7c27bafd (diff)
[IMP] gunicorn: changed `print` with `logging.info`.
bzr revid: vmt@openerp.com-20120120160409-cu1vcw7cfa3z0zgy
-rw-r--r--gunicorn.conf.py2
-rw-r--r--openerp/tests/addons/test_limits/models.py5
-rw-r--r--openerp/wsgi.py10
3 files changed, 5 insertions, 12 deletions
diff --git a/gunicorn.conf.py b/gunicorn.conf.py
index 4d85fa2b6c0..db570401d17 100644
--- a/gunicorn.conf.py
+++ b/gunicorn.conf.py
@@ -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
diff --git a/openerp/tests/addons/test_limits/models.py b/openerp/tests/addons/test_limits/models.py
index 435e93811fc..5240acd23ab 100644
--- a/openerp/tests/addons/test_limits/models.py
+++ b/openerp/tests/addons/test_limits/models.py
@@ -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:
diff --git a/openerp/wsgi.py b/openerp/wsgi.py
index ed03ed9bc6c..7d47cdb7bb6 100644
--- a/openerp/wsgi.py
+++ b/openerp/wsgi.py
@@ -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