1 __MySQLdb = __import__('MySQLdb')
3 __all__ = __MySQLdb.__all__
4 __patched__ = ["connect", "Connect", 'Connection', 'connections']
6 from eventlet.patcher import slurp_properties
9 ignore=__patched__, srckeys=dir(__MySQLdb))
11 from eventlet import tpool
13 __orig_connections = __import__('MySQLdb.connections').connections
16 def Connection(*args, **kw):
17 conn = tpool.execute(__orig_connections.Connection, *args, **kw)
18 return tpool.Proxy(conn, autowrap_names=('cursor',))
19 connect = Connect = Connection
22 # replicate the MySQLdb.connections module but with a tpooled Connection factory
23 class MySQLdbConnectionsModule(object):
26 connections = MySQLdbConnectionsModule()
27 for var in dir(__orig_connections):
28 if not var.startswith('__'):
29 setattr(connections, var, getattr(__orig_connections, var))
30 connections.Connection = Connection
32 cursors = __import__('MySQLdb.cursors').cursors
33 converters = __import__('MySQLdb.converters').converters
35 # TODO support instantiating cursors.FooCursor objects directly
36 # TODO though this is a low priority, it would be nice if we supported
37 # subclassing eventlet.green.MySQLdb.connections.Connection