No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

38 líneas
1.2KB

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