Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Gevent with SQL Alchemy and Pyodbc #5408
Comments
|
pyodbc doesn't have any async capbiltities. the only database among those supported that itself has async capabilitiy as all is postgresql. there's some discussion about postgresql with pyodbc and async at mkleehammer/pyodbc#348 and essentially there's no real rationale for it to support this. there's no actual reason to use gevent with relational database access however and it will only make your code less reliable and more difficult to debug. I speak from considerable experience in this area. |
|
@zzzeek I agree the code can become less reliable and difficult to debug. However, I believe there will be performance improvements for the application in general due to the async approach if the application is I/O bound. For example, here http://blog.devsda.fr/python-gevent.html they reported significant performance improvements when using gevent with pymssql. |
|
So I can't get you gevent support here, and also my studied opinion is that it's very hard to make Python IO bound with a high performance database on a local network, as it is not Go, Erlang, Node, or C, it's interpreted Python and has very high CPU overhead relative to compiled languages , see https://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-databases/ , http://calpaterson.com/async-python-is-not-faster.html etc. I have yet to see a real benchmark showing async Python to be faster. Also with the monkeypatching approach you put yourself in great danger of CPU bound processes hanging up your database, I've dealt with an actual outage of that nature, and additionally I've dealt with several across multiple applications which were directly caused by the usage of eventlet or gevent which would then pile up requests that were blocked due to mis-configuration of the number of greenlets relative to what the database was tailored for. |
|
@zzzeek thx for the explanation |
|
in case it helps SQLAlchemy 1.4 will have native asyncio support. no path for pyodbc that I'm familiar with though :(. closing this for now. |
|
ok thx |
I've tried to search in Google, but I haven't had good results.
Is it possible to use gevent with SQL Alchemy and pyodbc?
I could make it work with my current Flask Restplus application, but when SQL Alchemy comes into play, the async behavior stop working.