0

I'm using SqlAlchemy to connect to Oracle SQL with a multiprocess python application.

I have multiple (100-200) python workers that need to connect to the Oracle and I want to create a connection pool.

From what I understand, you can pass a connection pool when you fork a new process, my problem is that I use supervisord to spawn the python workers.

Is it possible to share a connection pool with supervisor? maybe tweak supervisor to create the connection pool and pass it to the child processes?

If not, can someone share an example how to use SqlAlchemy connection pool?

Amir Rossert
  • 226
  • 2
  • 15
  • You can sort of pass a pool when you fork, but you [must not pass any connections](http://docs.sqlalchemy.org/en/latest/core/pooling.html#using-connection-pools-with-multiprocessing), or you'll get [interesting results](http://stackoverflow.com/questions/41279157/connection-problems-with-sqlalchemy-and-multiple-processes/41722129#41722129)... – Ilja Everilä Feb 24 '17 at 23:26
  • It seems some Oracle DB product has [DB resident connection pooling](https://docs.oracle.com/cd/B28359_01/server.111/b28310/manproc004.htm#ADMIN12349). Maybe that could help? I know next to nothing about Oracle, so it might not even be related. – Ilja Everilä Feb 24 '17 at 23:35
  • I understand that I can pass the pool when forking by I'm using supervisord so I'm not the one that actually using the fork – Amir Rossert Feb 25 '17 at 10:36
  • It's just not much of a pool really, as you must not share connections between forked processes, and so each process ends up with a pool of their own. Moving the pooling out seems to me like the way to go in your case. – Ilja Everilä Feb 25 '17 at 11:52
  • I think the real question should be "Can I use SQLAlchemy with Oracle DRCP" – Ilja Everilä Feb 25 '17 at 12:09

0 Answers0