[Zodb-checkins] CVS: ZODB3/Tools - update.py:1.1.2.2
Jeremy Hylton
jeremy@zope.com
Tue, 17 Dec 2002 15:42:49 -0500
Update of /cvs-repository/ZODB3/Tools
In directory cvs.zope.org:/tmp/cvs-serv16274/Tools
Modified Files:
Tag: ZODB3-fast-restart-branch
update.py
Log Message:
Check in the latest update script.
=== ZODB3/Tools/update.py 1.1.2.1 => 1.1.2.2 ===
--- ZODB3/Tools/update.py:1.1.2.1 Tue Dec 17 12:34:33 2002
+++ ZODB3/Tools/update.py Tue Dec 17 15:42:49 2002
@@ -1,19 +1,29 @@
#! /usr/bin/env python2.1
import random
+import time
import ZODB
from ZEO.ClientStorage import ClientStorage
+from ZEO.Exceptions import Disconnected
SERVER = "guido", 9000
MB = 1024**2
CACHE_SIZE = 200 * MB
CLIENT = "cache"
-RECONNECT_TIMEOUT = 10
+RECONNECT_TIMEOUT = 2
NEARLY_FULL = CACHE_SIZE * 0.45
+def update(objs):
+ i = random.randint(0, len(objs))
+ obj = objs[i]
+ size = 2 ** random.randint(1, 20)
+ obj.value = "u" * size
+ get_transaction().commit()
+
def main():
+ global cs
cs = ClientStorage(SERVER, cache_size=CACHE_SIZE, client=CLIENT,
max_disconnect_poll=RECONNECT_TIMEOUT)
db = ZODB.DB(cs)
@@ -24,16 +34,18 @@
cache = cs._cache
num_objs = len(objs)
- j = 0
- while cache._pos < NEARLY_FULL:
- print "cache size", cache._pos
- i = random.randint(0, num_objs)
- obj = objs[i]
- size = 2 ** random.randint(1, 20)
- obj.value = "u" * size
- j += 1
- if j % 20 == 0:
- get_transaction().commit()
+ while 1:
+ try:
+ time.sleep(1.5)
+ update(objs)
+ except Disconnected, err:
+ print err
+ disconnected = 1
+ else:
+ disconnected = 0
+ if disconnected:
+ get_transaction().abort()
+ time.sleep(1)
if __name__ == "__main__":
main()