Skip to content

Commit

Permalink
Using SingletonThreadPool for MySQL connection for thread safety and …
Browse files Browse the repository at this point in the history
…connection recycling
  • Loading branch information
vindimy committed Apr 19, 2013
1 parent 3416c50 commit 6a82729
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/btctip/db.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python

from sqlalchemy import create_engine, Table, Column, Integer, String, MetaData, ForeignKey, Numeric, UnicodeText
from sqlalchemy.pool import SingletonThreadPool

class BitcointipDatabase:

Expand Down Expand Up @@ -73,6 +74,6 @@ def __init__(self, dsn_url):

def connect(self):
'''Return a connection object'''
engine = create_engine(self.dsn_url)
engine = create_engine(self.dsn_url, echo_pool=True, pool_recycle=60, poolclass=SingletonThreadPool)
self.metadata.create_all(engine)
return engine
return engine

0 comments on commit 6a82729

Please sign in to comment.