From 30d7253fef235bbb117aeec0a27c7c5e3c436c4a Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Fri, 20 Jan 2012 17:04:09 +0100 Subject: [PATCH] [IMP] gunicorn: changed `print` with `logging.info`. bzr revid: vmt@openerp.com-20120120160409-cu1vcw7cfa3z0zgy --- gunicorn.conf.py | 2 +- openerp/tests/addons/test_limits/models.py | 5 ----- openerp/wsgi.py | 10 ++++------ 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