Commit 8b16fc79 authored by Jim Fulton's avatar Jim Fulton

Added sync method in support of the ZODB Connection sync method.

parent 1cc1e605
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""Network ZODB storage client """Network ZODB storage client
""" """
__version__='$Revision: 1.25 $'[11:-2] __version__='$Revision: 1.26 $'[11:-2]
import struct, time, os, socket, string, Sync, zrpc, ClientCache import struct, time, os, socket, string, Sync, zrpc, ClientCache
import tempfile, Invalidator, ExtensionClass, thread import tempfile, Invalidator, ExtensionClass, thread
...@@ -559,6 +559,8 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage): ...@@ -559,6 +559,8 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage):
try: return self._call('versions', max) try: return self._call('versions', max)
finally: self._lock_release() finally: self._lock_release()
def sync(self): self._call.sync()
def getWakeup(_w=[]): def getWakeup(_w=[]):
if _w: return _w[0] if _w: return _w[0]
import trigger import trigger
......
...@@ -85,13 +85,13 @@ ...@@ -85,13 +85,13 @@
"""Simple rpc mechanisms """Simple rpc mechanisms
""" """
__version__ = "$Revision: 1.10 $"[11:-2] __version__ = "$Revision: 1.11 $"[11:-2]
from ZODB.cPickle import loads from ZODB.cPickle import loads
from ZODB import cPickle from ZODB import cPickle
from thread import allocate_lock from thread import allocate_lock
from smac import SizedMessageAsyncConnection from smac import SizedMessageAsyncConnection
import socket, string, struct, asyncore, sys, time import socket, string, struct, asyncore, sys, time, select
TupleType=type(()) TupleType=type(())
from zLOG import LOG, TRACE, DEBUG, INFO from zLOG import LOG, TRACE, DEBUG, INFO
...@@ -163,6 +163,17 @@ class asyncRPC(SizedMessageAsyncConnection): ...@@ -163,6 +163,17 @@ class asyncRPC(SizedMessageAsyncConnection):
if key==self._fileno: return self if key==self._fileno: return self
raise KeyError, key raise KeyError, key
def sync(self):
if self.__map: return # in async mode
# Ick, I have to do my own select loop, which sucks
while 1:
try: r, w, e = select.select([self._fileno],[],[],0.0)
except select.error, v:
if v[0] != EINTR: raise
if r: asyncore.poll(0.0, self)
else: break
def readLoop(self): def readLoop(self):
la=self.__la la=self.__la
while not la(0): while not la(0):
...@@ -176,6 +187,7 @@ class asyncRPC(SizedMessageAsyncConnection): ...@@ -176,6 +187,7 @@ class asyncRPC(SizedMessageAsyncConnection):
self.__map=1 self.__map=1
self.__Wakeup=Wakeup self.__Wakeup=Wakeup
def __call__(self, *args): def __call__(self, *args):
args=dump(args,1) args=dump(args,1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment