Beispiel #1
0
 def call(self, *arg, **kw):
     if debugCall: print "Call:", arg, kw
     id = thread.get_ident()
     if id not in self.readlocks:
         if debugThreads: print "Call: Making readlock for", id
         self.readlocks[id] = threading.Condition()
     if debugThreads: print "Call: Locking readlock for", id
     self.readlocks[id].acquire()
     if debugThreads: print "Call: Locked readlock for", id
     if self.err is not None:
         if debugThreads: print "Call: Releasing readlock for", id
         self.readlocks[id].release()
         if debugThreads: print "Call: Released readlock for", id
         raise self.err
     try:
         self.write(('RPCCall', id, arg, kw))
         while self.err is None and id not in self.res:
             if debugThreads: print "Call: Waiting on readlock for", id
             self.readlocks[id].wait()
             if debugThreads: print "Call: Waiting on readlock for", id, "done"
         res = self.res[id]
         del self.res[id]
         err = self.err
     finally:
         if debugThreads: print "Call: Releasing readlock for", id
         self.readlocks[id].release()
         if debugThreads: print "Call: Released readlock for", id
     if err:
         raise err
     res = Reader.extend(res, self.extension.parse)
     if debugResult: print "Result:", res
     return res
Beispiel #2
0
 def dispatchThread(msg, callindex):
     msg = Reader.extend(msg, self.extension.parse)
     if debugDispatch or profileDispatch: print "Dispatch " + str(callindex[0]) + ":", msg
     try:
         res = self.dispatch(*msg[1], **msg[2])
     except:
         exc_type, exc_value = sys.exc_info()[:2]
         e = exc_value or exc_type
         if Grimoire.Utils.isInstance(e, *debugExceptions) and not Grimoire.Utils.isInstance(e, *dontDebugExceptions):
             import traceback
             traceback.print_exc()
         res = Types.RaiseException()
     self.write(('RPCCallReturn', msg[0], res))