Currently, this driver doesn't support the critical commit section. This is because there is only one global wait callback allowed for the entire process, and the driver doesn't supply individual functions to poll for reading and writing and a low-level query function (as opposed to MySQLdb, which has those things; that granularity is what allows it to work).
However, I think we can actually get pretty close.
Suppose the Connection object, which is passed to the wait callback, gains a new attribute that lets us know if we're in the critical section or not. Then, if it is, instead of calling select.select to do the polling in the wait callback (which assumes we're monkey-patched, so it ultimately calls gevent.select.select) the wait callback could ask gevent for the original (blocking) select.select and use that instead.
The main downside I see is that we don't know what query we are polling for (we could use that to release the critical section before committing, for example). But the MySQL integration doesn't use that anyway, and if we wanted to do that we could do so at a higher level.
This seems very simple, and I'm wondering why I didn't think of it before. Perhaps I'm overlooking something now?
Currently, this driver doesn't support the critical commit section. This is because there is only one global wait callback allowed for the entire process, and the driver doesn't supply individual functions to poll for reading and writing and a low-level query function (as opposed to MySQLdb, which has those things; that granularity is what allows it to work).
However, I think we can actually get pretty close.
Suppose the Connection object, which is passed to the wait callback, gains a new attribute that lets us know if we're in the critical section or not. Then, if it is, instead of calling
select.select
to do the polling in the wait callback (which assumes we're monkey-patched, so it ultimately callsgevent.select.select
) the wait callback could ask gevent for the original (blocking)select.select
and use that instead.The main downside I see is that we don't know what query we are polling for (we could use that to release the critical section before committing, for example). But the MySQL integration doesn't use that anyway, and if we wanted to do that we could do so at a higher level.
This seems very simple, and I'm wondering why I didn't think of it before. Perhaps I'm overlooking something now?
/cc @jzuech3 @cutz