Marc Abramowitz
2013-09-27 00:52:02 UTC
Today, a colleague and I got excited about making pymssql "green" by
supporting "green" thread implementations like gevent by adding a callback
to pymssql that it would call after the query has been sent and before the
results are received. One could have this callback call something like
gevent.sleep() to yield control to another greenlet.
I implemented a very basic version of this that calls the callback after
calling dbsqlsend and before calling dbsqlok (which blocks) [1]. This very
basic implementation kind of helps in some cases because yielding after the
dbsqlsend gives other coroutines a chance to run but it's not fully green
because the dbsqlok is a blocking operation so when it gets hit it will
block all coroutines.
What I'd really like to get do is use the dbdataready [1] function of
DB-API so that I can avoid blocking on dbsqlok. Unfortunately, it seems
that it was never implemented in FreeTDS
Are there any plans to implement dbdataready or the dbpoll, the Sybase
flavor of async?
Marc
[1] https://github.com/pymssql/pymssql/pull/133/files
[2] http://technet.microsoft.com/en-us/library/aa937037.aspx
supporting "green" thread implementations like gevent by adding a callback
to pymssql that it would call after the query has been sent and before the
results are received. One could have this callback call something like
gevent.sleep() to yield control to another greenlet.
I implemented a very basic version of this that calls the callback after
calling dbsqlsend and before calling dbsqlok (which blocks) [1]. This very
basic implementation kind of helps in some cases because yielding after the
dbsqlsend gives other coroutines a chance to run but it's not fully green
because the dbsqlok is a blocking operation so when it gets hit it will
block all coroutines.
What I'd really like to get do is use the dbdataready [1] function of
DB-API so that I can avoid blocking on dbsqlok. Unfortunately, it seems
that it was never implemented in FreeTDS
Are there any plans to implement dbdataready or the dbpoll, the Sybase
flavor of async?
Marc
[1] https://github.com/pymssql/pymssql/pull/133/files
[2] http://technet.microsoft.com/en-us/library/aa937037.aspx