Ejemplo n.º 1
0
 def _runQuery(self, qstr, eater, chunkSize):
     print 'running query'
     conn = self.connect()
     curs = conn.cursor()
     try:
         curs.execute(qstr)
         print 'ran it!'
         if eater is not None:
             task.schedule(eater, curs.fetchmany(chunkSize))
             result = None
         else:
             result = curs.fetchall()
     except:
         print 'oops!'
         conn.rollback()
         traceback.print_exc()
         raise
     return result
Ejemplo n.º 2
0
 def _runQuery(self, qstr, eater, chunkSize):
     print 'running query'
     conn = self.connect()
     curs = conn.cursor()
     try:
         curs.execute(qstr)
         print 'ran it!'
         if eater is not None:
             task.schedule(eater, curs.fetchmany(chunkSize))
             result = None
         else:
             result = curs.fetchall()
     except:
         print 'oops!'
         conn.rollback()
         traceback.print_exc()
         raise
     return result
Ejemplo n.º 3
0
 def send(self, data):
     """Schedule data to be written in a thread-safe manner"""
     # instead of doing self.transport.write(data), which is not
     # thread safe, we do:
     task.schedule(self.transport.write, data)
Ejemplo n.º 4
0
 def makeData(self):
     self.transport.write("twistedzombies")
     # schedule this function to be called
     t = task.Task()
     t.addWork(self.makeData)
     task.schedule(t)