How to handle sockets - easily?

William Ahern william at wilbur.25thandClement.com
Wed Feb 16 21:05:51 EST 2011


Bubba <nickname at banelli.biz.invalid> wrote:
> William Ahern's log on stardate 16 vlj 2011

> /snip

> > I think that there's an asynchronous all-Python MySQL library, but
> > I'm not sure. Maybe one day I can open source my asynchronous MySQL C
> > library. (I always recommend people to use PostgreSQL, though; which
> > is superior in almost every way, especially the C client library and
> > the wire protocol.) 

> I have no particular problem with using PgSQL.

> Which of these would you recommend? http://wiki.postgresql.org/wiki/Python

I don't use Python so I couldn't recommend one over another. I just took an
interest in your earlier post because I saw MySQL and asynchronous mentioned
together. It instantly occurred to me that there might be a conflict there,
and quickly reading the Python MySQLdb manual page confirmed this because it
seemed clear that it was just binding the C client API.

The PostgreSQL C client API supports asynchronous I/O, and the API and
protocol support interleaved requests over a single connection. But it's up
to the Python module writer to expose that functionality, and expose it in a
convenient and stylistically proper manner. Even if all the modules expose
the functionality, as I don't work in Python I couldn't say which does it
better.

Also, of course, there's no substitute for testing. For your particular
needs in your particular environment MySQL may work more performantly even
with its faults and the kludgy workarounds necessary. I was just warning
that you can't let a single client connection hold onto a MySQL connection
object for the duration of the client connection's lifetime, and probably
don't want the SQL requests to occur on the same thread as the client
handlers; at least without understanding the consequences.



More information about the Python-list mailing list