�  File "/home/mark/work/common/web/db.py", line 529, in query
    db_cursor = self._db_cursor()
  File "/home/mark/work/common/web/db.py", line 448, in _db_cursor
    return self.ctx.db.cursor()
  File "/home/mark/work/common/web/db.py", line 407, in _getctx
    self._load_context(self._ctx)
  File "/home/mark/work/common/web/db.py", line 416, in _load_context
    ctx.db = self._connect_with_pooling(self.keywords)
  File "/home/mark/work/common/web/db.py", line 829, in _connect_with_pooling
    conn = DB._connect_with_pooling(self, keywords)
  File "/home/mark/work/common/web/db.py", line 445, in _connect_with_pooling
    return self._pooleddb.connection()
  File "/usr/lib/python2.5/site-packages/DBUtils-0.9.4-py2.5.egg/DBUtils/PooledDB.py", line 262, in connection
    self._condition.wait()
  File "/usr/lib/python2.5/site-packages/DBUtils-0.9.4-py2.5.egg/DBUtils/PooledDB.py", line 216, in wait
    raise TooManyConnections
TooManyConnections" while reading upstream, client:

select count(*) from pg_stat_activity where current_query = '<IDLE>';
 count
-------
   756
(1 row)

 select count(*)  from pg_stat_activity where current_query != '<IDLE>';
 count
-------
     6
(1 row)



This is the QUeue module for bg threads
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from Queue import Queue
from threading import Thread
import logging
import sys

APP_NAME=''
num_worker_threads = 5

logger = logging.getLogger('q')
hdlr = logging.FileHandler('/tmp/funq.log')
formatter = logging.Formatter('%(name)s: %(asctime)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.INFO)

def workerplain():
    while True:
        (f, args, kwargs) = q.get()
        f(*args, **kwargs)
        q.task_done()


def worker():
    while True:
        (function, args, kwargs) = q.get()
        data="">         try:
            function(*args, **kwargs)
        except:
            tb = sys.exc_info()
            subj = ' %s : %s ' %(tb[0], tb[1])
            logger.info('failed: ' + APP_NAME + subj  + str(data))
        else:
            logger.info('success: ' + APP_NAME + ' '+  str(data))

        try:q.task_done()
    except:pass

q = Queue()
for i in range(num_worker_threads):
    t = Thread(target=worker)
    t.setDaemon(True)
    t.start()

#from globalstuff import db
#from app import setFBML
#for i in db.query("select uid from users limit 1000"):
#    q.put((setFBML, (i.uid,),dict(bg=False)))
#q.put((f, (), {})) this is no args
#q.join()       # block until all tasks are done


and in app i do

import funcq_common
funcq_common.q.put(funcname, [list of args], dict(kw arg))

any ideas of how to grab and release db connections in this Q


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to