Commit 45cca84a authored by Jim Fulton's avatar Jim Fulton

Added ClientStorage option to wait for a connection to the server

on start up, with the default being to wait for the server.

The intent was that it should be possible to bring a client up even
if it can't talk to the server, however, this is a little bit risky if
we need to start them both.  Eventually, we need to be the start-up
code be smart enough to wait if we can't serve data requests during
startup, but to proceed if we can.
parent 0fe92131
......@@ -84,7 +84,7 @@
##############################################################################
"""Network ZODB storage client
"""
__version__='$Revision: 1.19 $'[11:-2]
__version__='$Revision: 1.20 $'[11:-2]
import struct, time, os, socket, string, Sync, zrpc, ClientCache
import tempfile, Invalidator, ExtensionClass, thread
......@@ -117,7 +117,8 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage):
def __init__(self, connection, async=0, storage='1', cache_size=20000000,
name='', client='', debug=0, var=None,
min_disconnect_poll=5, max_disconnect_poll=300):
min_disconnect_poll=5, max_disconnect_poll=300,
wait_for_server_on_starup=1):
# Decide whether to use non-temporary files
client=client or os.environ.get('ZEO_CLIENT','')
......@@ -125,6 +126,7 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage):
self._connection=connection
self._storage=storage
self._debug=debug
self._wait_for_server_on_starup=wait_for_server_on_starup
self._info={'length': 0, 'size': 0, 'name': 'ZEO Client',
'supportsUndo':0, 'supportsVersions': 0,
......@@ -194,7 +196,7 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage):
def _startup(self):
if not self._call.connect():
if not self._call.connect(not self._wait_for_server_on_starup):
# If we can't connect right away, go ahead and open the cache
# and start a separate thread to try and reconnect.
......
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