Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
62016a67
Commit
62016a67
authored
Jul 15, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d486c5c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
14 deletions
+16
-14
wcfs/__init__.py
wcfs/__init__.py
+14
-14
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+2
-0
No files found.
wcfs/__init__.py
View file @
62016a67
...
...
@@ -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.
...
...
wcfs/wcfs_test.py
View file @
62016a67
...
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment