Twisted adbapi fetchone -


if use runinteraction of twisted's adbapi, , within function call like

curs. execute("select id mytable name='bob'") id = curs.fetchone()[0] 

am guaranteed id select or 1 of other deferred threads?

deferreds thread-safe can guarantee.

example code lookslike:

def _getage(txn, user):     # run in thread, can use blocking calls     txn.execute("select * foo")     # ... other cursor commands called on txn ...     txn.execute("select age users name = ?", user)     result = txn.fetchall()     if result:         return result[0][0]     else:         return none  def getage(user):     return dbpool.runinteraction(_getage, user)  def printresult(age):     if age != none:         print age, "years old"     else:         print "no such user"  getage("joe").addcallback(printresult) 

this official docs. didn't remove row more clear , teaching.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -