[IMP] gunicorn: changed `print` with `logging.info`.
authorVo Minh Thu <vmt@openerp.com>
Fri, 20 Jan 2012 16:04:09 +0000 (17:04 +0100)
committerVo Minh Thu <vmt@openerp.com>
Fri, 20 Jan 2012 16:04:09 +0000 (17:04 +0100)
bzr revid: vmt@openerp.com-20120120160409-cu1vcw7cfa3z0zgy

gunicorn.conf.py
openerp/tests/addons/test_limits/models.py
openerp/wsgi.py

index 4d85fa2..db57040 100644 (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
index 435e938..5240acd 100644 (file)
@@ -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:
index ed03ed9..7d47cdb 100644 (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