[ZODB-Dev] ZEO pack

Greg Ward gward@mems-exchange.org
Wed, 26 Sep 2001 09:54:45 -0400


On 26 September 2001, Chris Withers said:
> Am I right in observing that when you do, for example, a manage_pack
> from a ZEO client, this is a non-blocking operation that returns
> prettymuch instantaneously?

That's what we have observed.

> How does the process work?

Wish I knew.

> Is there any way I can _make_ the above block?

If your ZEO server sits atop a FileStorage, it looks as though the pack
is finished when the ".fs.old" file comes into existence.  Here's how we
do a blocking pack via ZEO (hold your nose, this stinks):

  SOURCE_FILE_PATH = '/www/var/mxdb.fs'
  OLD_SOURCE_FILE = SOURCE_FILE_PATH + '.old'
  [...]
  if os.path.exists(OLD_SOURCE_FILE):
      os.unlink(OLD_SOURCE_FILE)
  [...]
  init_database()                   # sets things up 
  db = get_database()               # returns a ZODB.DB.DB instance
  db.pack(time.time())
  close_database()                  # shuts things down
  [...]
  secs = 0
  while not os.path.exists(OLD_SOURCE_FILE):
      secs += 1
      if secs > WAIT_TIME*60:
          break
      time.sleep(1)

  if not os.path.exists(OLD_SOURCE_FILE):
      die('%s was not created after waiting %s seconds ' %
          (OLD_SOURCE_FILE, secs))

Bleccchhhh.  I wish there were a better way!

        Greg
-- 
Greg Ward - software developer                gward@mems-exchange.org
MEMS Exchange                            http://www.mems-exchange.org