gevent::AsyncResult

gevent::AsyncResult
看到 AsyncResult这个类,想到我之前自己写的处理异步返回值的类 

 1  class MutexObject:
 2      def  __init__(self):
 3         self.mtx = threading.Condition()
 4         self.d = None
 5         
 6      def waitObject(self,timeout):
 7         d = None
 8         self.mtx.acquire()
 9          if self.d == None:
10              if timeout:
11                 self.mtx.wait(timeout)
12              else:
13                 self.mtx.wait()
14             d = self.d
15             self.d = None
16         self.mtx.release()
17          return d
18         
19      def notify(self,d):
20         self.mtx.acquire()
21         self.d = d
22         self.mtx.notify()
23         self.mtx.release()

你可能感兴趣的:(gevent::AsyncResult)