Commit 62016a67 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d486c5c4
......@@ -25,7 +25,7 @@ will be automatically started if `autostart=True` parameter is passed to join.
It will also be automatically started by default unless
$WENDELIN_CORE_WCFS_AUTOSTART=no is specified in environment.
Conn represents connection to wcfs server obtained by join.
WCFS represents connection to wcfs server obtained by join.
FileH ... XXX
XXX
......@@ -38,22 +38,24 @@ import logging as log
from os.path import dirname
from errno import ENOENT, EEXIST
from golang import chan, select, default
from golang import chan, select, default, func
from golang import sync, context
from golang.gcompat import qq
import threading
from ZODB.FileStorage import FileStorage
from ZODB.utils import u64, p64
from zodbtools.util import ashex
# Conn represents connection to wcfs server.
class Conn(object):
# WCFS represents connection to wcfs server.
# Only 1 connection is maintained for one file server.
class WCFS(object):
# .mountpoint path to wcfs mountpoint
# ._fwcfs /.wcfs/zurl opened to keep the server from going away (at least cleanly)
# XXX for-testing only?
# ._proc wcfs process if it was opened by this conn | None
# ._proc wcfs process if it was opened by this WCFS | None
def __init__(self, mountpoint, fwcfs, proc):
self.mountpoint = mountpoint
......@@ -161,7 +163,7 @@ def _default_autostart():
# If wcfs for that zurl was already started, join connects to it.
# Otherwise it starts wcfs for zurl if autostart is True.
#
# If shared is True - a shared connection is returned - one that will be also
# If shared is True - a shared connection is returned - one that will be also XXX -> always this way
# returned for following join(shared=True) requests with the same zurl.
def join(zurl, autostart=_default_autostart(), shared=False): # -> Conn
# XXX implement shared
......@@ -177,14 +179,12 @@ def join(zurl, autostart=_default_autostart(), shared=False): # -> Conn
raise
else:
# already have it
return Conn(mntpt, f, None)
return WCFS(mntpt, f, None)
if not autostart:
raise RuntimeError("wcfs: join %s: server not started" % zurl)
# start wcfs with telling it to automatically exit when there is no client activity.
# XXX extra opts -> join args -> test + -v=1 if running py.test -v
# XXX ^^^ check log level?
optv_extra = os.environ.get("WENDELIN_CORE_WCFS_OPTIONS", "").split()
return _start(zurl, "-autoexit", *optv_extra)
......@@ -192,14 +192,14 @@ def join(zurl, autostart=_default_autostart(), shared=False): # -> Conn
# _start starts wcfs server for ZODB @ zurl.
#
# optv can be optionally given to pass flags to wcfs.
def _start(zurl, *optv): # -> Conn
def _start(zurl, *optv): # -> WCFS
mntpt = _mntpt_4zurl(zurl)
log.info("wcfs: starting for %s ...", zurl)
# XXX errctx "wcfs: start"
# spawn wcfs and wait till filesystem-level access to it is ready
conn = Conn(mntpt, None, None)
wc = WCFS(mntpt, None, None)
wg = sync.WorkGroup(context.background())
fsready = chan()
def _(ctx):
......@@ -221,7 +221,7 @@ def _start(zurl, *optv): # -> Conn
raise ctx.err()
if _ == 1:
# startup was ok - don't monitor spawned wcfs any longer
conn._proc = proc
wc._proc = proc
return
time.sleep(0.1)
......@@ -240,7 +240,7 @@ def _start(zurl, *optv): # -> Conn
if dotwcfs != zurl:
raise RuntimeError(".wcfs/zurl != zurl (%s != %s)" % (qq(dotwcfs), qq(zurl)))
conn._fwcfs = f
wc._fwcfs = f
fsready.close()
return
......@@ -255,7 +255,7 @@ def _start(zurl, *optv): # -> Conn
wg.go(_)
wg.wait()
return conn
return wc
# _wcfs_exe returns path to wcfs executable.
......
......@@ -49,6 +49,8 @@ from six import reraise
from .internal import io, mm
from .internal.wcfs_test import read_nogil, install_sigbus_trap, fadvise_dontneed
# XXX `py.test -v` -> WENDELIN_CORE_WCFS_OPTIONS += -v=1?
# setup:
# - create test database, compute zurl and mountpoint for wcfs
# - at every test: make sure wcfs is not running before & after the test.
......
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