[Zodb-checkins] CVS: Packages/ZEO - zrpc2.py:1.1.2.12

jeremy@digicool.com jeremy@digicool.com
Tue, 1 May 2001 18:35:04 -0400 (EDT)


Update of /cvs-repository/Packages/ZEO
In directory korak:/tmp/cvs-serv20475

Modified Files:
      Tag: ZEO-ZRPC-Dev
	zrpc2.py 
Log Message:
Add a call lock so that only a single call can be outstanding at one
time.  This isn't a long-term solution, but allows ClientStorage sans
synchronized methods to function correctly.






--- Updated File zrpc2.py in package Packages/ZEO --
--- zrpc2.py	2001/04/25 22:15:22	1.1.2.11
+++ zrpc2.py	2001/05/01 22:35:03	1.1.2.12
@@ -145,6 +145,7 @@
         # waiting for a response
         self.__super_init(sock, addr)
         self._prepare_async()
+        self.__call_lock = thread.allocate_lock()
         self.__reply_lock = thread.allocate_lock()
         self.__reply_lock.acquire()
         if isinstance(obj, Handler):
@@ -287,6 +288,13 @@
     # synchronous calls
 
     def call(self, method, *args):
+        self.__call_lock.acquire()
+        try:
+            return self._call(method, args)
+        finally:
+            self.__call_lock.release()
+
+    def _call(self, method, args):
         if self.closed:
             raise DisconnectedError("This action is temporarily unavailable")
         msgid = self.msgid
@@ -310,6 +318,13 @@
         return r_args
 
     def callAsync(self, method, *args):
+        self.__call_lock.acquire()
+        try:
+            self._callAsync(method, args)
+        finally:
+            self.__call_lock.release()
+
+    def _callAsync(self, method, args):
         if self.closed:
             raise DisconnectedError("This action is temporarily unavailable")
         msgid = self.msgid