Pool not working only 1 connetion managed

Bug #488939 reported by Mindtilt
This bug report is a duplicate of:  Bug #488928: Thread locking issue. Edit Remove
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PySQLPool
New
Undecided
Nikoleta Verbeck

Bug Description

I tested the version 0.3.5 + python 2.5 (windows) + multiple threads and it always open only 1 mysql connection, no matter what i try, so i guess pool is not working.

With version 0.3.4 + python 2.5(windows) + multiple threads pool works only with different variable names.
If you loop same varible only a single connection is pooled,

code:
connections.py module

mport PySQLPool,datetime

class Connections(object):

    __pool= None
    __connection=None

    def __init__(self,host='localhost',username='ploonorkut',password='19780327',schema='postx'):

       self.__connection = PySQLPool.getNewConnection(host, username, password, schema)
       PySQLPool.PySQLConnection.connection_timeout = datetime.timedelta(86400)
       self.__pool = PySQLPool.getNewPool()
       self.__pool.GetConnection(self.__connection)
       self.__pool.maxActiveConnections=5
       self.__pool.maxActivePerConnection=1

    def returnQuery(self):

        query= PySQLPool.getNewQuery(self.__connection,True)

        return query
    #def returnConnection(self,query):
    # self.__pool.returnConnection(query)
    #def clean(self):
    # self.__pool.Cleanup()
    def close(self):
        self.__pool.Terminate()
    def commit(self):
        self.__pool.Commit()

test module:
import Connections
import threading

class comunidade(threading.Thread):
    def run(self):
        con = Connections.Connections()
        query = con.returnQuery()
        for i in range(1,7000):

            query.Query('select nmComunidade from orkutcomunidade limit 10')

            for row in query.record:
                print row['nmComunidade']

#Pooling works with this code version 0.3.4 (single connection with version 0.3.5)
c=comunidade()
ca=comunidade()
ci=comunidade()
c.start()
ca.start()
ci.start()
#Single connection, pooling not working with this code
c = comunidade()
for i in range (1,4):
   c.start()

Revision history for this message
Mindtilt (rcamati) wrote :

You will get
Traceback (most recent call last):
  File "D:\Development\eclipse\workspace\python\PloonOrkut\src\control\Main.py", line 20, in <module>
    cm.start()
  File "C:\Arquivos de programas\python25\lib\threading.py", line 434, in start
    raise RuntimeError("thread already started")
RuntimeError: thread already started
if execute the code
c = comunidade()
for i in range (1,4):
   c.start()

please do :

#Single connection, pooling not working with this code
for i in range (1,4):
   c = comunidade()
   c.start()

Changed in pysqlpool:
assignee: nobody → Nick Verbeck (nerdynick)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.