pymysql and gevent

772 views
Skip to first unread message

urielka

unread,
Sep 3, 2010, 9:43:26 AM9/3/10
to gevent: coroutine-based Python network library
has anyone tried PyMYSQL with gevent?
http://code.google.com/p/pymysql/

I tried the python-connector and it was casuing some deadlocks
somewhere so i ditched that in favor for dbslayer http proxy,but i
prefer to use a true connector instead of a proxy :)

Denis Bilenko

unread,
Sep 4, 2010, 12:24:43 AM9/4/10
to gev...@googlegroups.com
Hi Uriel,

Have you seen http://github.com/mthurlin/gevent-MySQL ?
I've not used it myself, but it seems to be something worth trying.

Cheers,
Denis.

Andy

unread,
Sep 4, 2010, 2:27:43 PM9/4/10
to gevent: coroutine-based Python network library
Hi Denis,

What does it mean to have a database driver made specifically for
gevent?

According to its site, gevent-MySQL is based on the async Concurrence
MySQL driver.

If a database driver is async, which the Concurrence driver is,
shouldn't it just work with gevent? Why is it necessary to modify the
Concurrence driver before it would work with gevent? What
modifications are needed?

I must be missing something.

On Sep 4, 12:24 am, Denis Bilenko <denis.bile...@gmail.com> wrote:
> Hi Uriel,
>
> Have you seenhttp://github.com/mthurlin/gevent-MySQL?

Markus Thurlin

unread,
Sep 4, 2010, 2:33:26 PM9/4/10
to gev...@googlegroups.com
You can't run code that calls Concurrence specific APIs without running Concurrence. Just like you can't run async Twisted code in gevent either :)

I am the maintainer of gevent-MySQL, and what has been modified is that all calls to the Concurrence API has been replaced by their counterparts in gevent.

/Markus

urielka

unread,
Sep 4, 2010, 5:36:49 PM9/4/10
to gevent: coroutine-based Python network library
what about usage in production?

On Sep 4, 9:33 pm, Markus Thurlin <mar...@esn.me> wrote:
> You can't run code that calls Concurrence specific APIs without running
> Concurrence. Just like you can't run async Twisted code in gevent either :)
>
> I am the maintainer of gevent-MySQL, and what has been modified is that all
> calls to the Concurrence API has been replaced by their counterparts in
> gevent.
>
> /Markus
>

Andy

unread,
Sep 5, 2010, 12:53:19 AM9/5/10
to gevent: coroutine-based Python network library
Markus,

Can you give some examples of the gevent APIs that gevent-MySQL needs
to call? I guess I just don't understand why does a database driver
need to call the gevent APIs. I mean I could use python-connector with
gevent and python-connector doesn't need to call any gevent APIs. So
why is it different for gevent-MySQL?

Thanks.

Markus Thurlin

unread,
Sep 5, 2010, 2:15:23 AM9/5/10
to gev...@googlegroups.com
The company I work for is using it in production, but we are mostly using it through an ORM so I can't be sure all the edge case problems have been found. 
There are atleast no known issues, and we have had no problems with it.

Markus Thurlin

unread,
Sep 5, 2010, 2:31:40 AM9/5/10
to gev...@googlegroups.com
The db-driver from Concurrence uses some non-pure python features such as buffers written in Pyrex, catches TaskletExit, special timeout handling, and uses its own socket class which has a different API from regular sockets.

While it is probably possible to rewrite it not to use any gevent/concurrence specific stuff, that was not my goal. For example, instead of using socket.socket and monkey patch it later, I used gevent.socket.


--
Markus Thurlin
Web Developer
• e-mail: mar...@esn.me
• skype: mthurlin
• phone: +46 (0)708 85 55 74

ESN Social Software AB
www.esn.me

Andy

unread,
Sep 5, 2010, 3:24:50 AM9/5/10
to gevent: coroutine-based Python network library
I see. Thanks for the explanation.

Andy

unread,
Sep 5, 2010, 3:25:27 AM9/5/10
to gevent: coroutine-based Python network library
Can you tell me what ORM you use with gevent-MySQL?

urielka

unread,
Sep 5, 2010, 5:54:51 PM9/5/10
to gevent: coroutine-based Python network library
second that,i guess if a ORM works on it,it is more than enough to fit
my needs
Reply all
Reply to author
Forward
0 new messages