From: Florian G\. P. <fg...@ph...> - 2003-05-06 14:59:42
|
Hi I discovered today that ruby-postgres uses the blocking postgres api when calling PGconn::exec / PGconn::query. This implies, that all other ruby threads are blocked until a result is available. There are, however, the function PGconn::async_exec and PGconn::async_query which properly use the nonblocking postgresql api, and use rb_thread_select to put the calling thread to sleep until the database backend responds. These functions are not, as the name might imply, truly asynchronous, in the sense that they return immediatly after sending the query. They seem (at least when reading the code) to be a drop-in replacement for exec and query, but with a more cooperative behaviour. I would recommend to use those functions in the postgres dbd module. I did not attach a patch, because simply replacing exec with async_exec is probably easier than applying a patch ;-)) greetings, Florian Pflug |