I am using Cogen in a Pylons web application. The Pylons controllers
wait for something to come into "myQueue" and then return the result.
I run another separate coro to poll the database, which put a result
into "myQueue". This setup works, but my problem is with blocking
MySQL queries (I use MySQLdb).
Most queries take just a millisecond or so. However, sometimes a more
complicated query takes longer. I want to allow one user to make this
query without blocking the entire server.
@coro
def process(self):
c = self.dbConn.cursor()
res = c.execute("SELECT SLEEP(5)") # We simulate a long query
c.close()
yield myQueue.publish("Got %d rows" % res)
This would have worked well if it wasn't for the long-lasting query.
What is the best solution to handle this? I consider the following:
1) Forking it, but how is that going to yield back the result?
2) Using a thread, but again I'm not sure how to use this with cogen
efficiently
3) Using a part of the cogen framework that handles this, I am not
sure what...
Any tips are appreciated!
Thanks
--
You received this message because you are subscribed to the Google Groups "cogen" group.
To post to this group, send email to
co...@googlegroups.com.
To unsubscribe from this group, send email to
cogen+un...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/cogen?hl=en.