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
c144b4a4
Commit
c144b4a4
authored
Jun 20, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7203d7ab
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
27 deletions
+30
-27
lib/tests/test_zodb.py
lib/tests/test_zodb.py
+0
-1
wcfs/__init__.py
wcfs/__init__.py
+27
-21
wcfs/client/_wczsync.pyx
wcfs/client/_wczsync.pyx
+1
-2
wcfs/client/_wczsync_test.py
wcfs/client/_wczsync_test.py
+2
-2
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+0
-1
No files found.
lib/tests/test_zodb.py
View file @
c144b4a4
...
...
@@ -370,7 +370,6 @@ def test_zodb_onshutdown():
t1
=
T
()
t2
=
T
()
t3
=
T
()
# conn1 stays alive outside of db.pool
conn1
=
db
.
open
()
...
...
wcfs/__init__.py
View file @
c144b4a4
...
...
@@ -20,14 +20,14 @@
"""Module wcfs.py provides python gateway for spawning and interoperating with wcfs server.
Serve(zurl) starts and runs WCFS server for ZODB at zurl.
Start(zurl) starts WCFS server for ZODB at zurl and returns corresponding Server object.
Join(zurl) joins wcfs server for ZODB at zurl and returns WCFS object that
represents filesystem-level connection to joined wcfs server. If wcfs server
for zurl is not yet running, it will be automatically started if join is given
`autostart=True` option.
Serve(zurl) starts and runs WCFS server for ZODB at zurl.
Start(zurl) starts WCFS server for ZODB at zurl and returns corresponding Server object.
The rest of wcfs.py merely wraps C++ wcfs client package:
- `WCFS` represents filesystem-level connection to wcfs server.
...
...
@@ -61,7 +61,7 @@ The following environment variables can be used to control wcfs.py client:
no join: don't spawn wcfs server unless explicitly requested via autostart=True
$WENDELIN_CORE_WCFS_OPTIONS
""
join/start
: additional options to pass to wcfs server when spawning it
""
serve/start/join
: additional options to pass to wcfs server when spawning it
"""
from
__future__
import
print_function
,
absolute_import
...
...
@@ -87,6 +87,17 @@ from .client._wcfs import \
PyPinReq
as
PinReq
\
# Server represents running wcfs server.
#
# Use start to create it.
class
Server
:
# .mountpoint path to wcfs mountpoint
# ._proc wcfs process
# ._fuseabort opened /sys/fs/fuse/connections/X/abort for this server
# ._stopOnce
pass
# WCFS represents filesystem-level connection to wcfs server.
#
# Use join to create it.
...
...
@@ -107,17 +118,6 @@ class WCFS(_WCFS):
pass
# Server represents running wcfs server.
#
# Use start to create it.
class
Server
:
# .mountpoint path to wcfs mountpoint
# ._proc wcfs process
# ._fuseabort opened /sys/fs/fuse/connections/X/abort for this server
# ._stopOnce
pass
# ---- WCFS raw file access (primarily for tests) ----
# _path returns path for object on wcfs.
...
...
@@ -279,15 +279,20 @@ def start(zurl, *optv): # -> Server
fwcfs
.
close
()
return
wcsrv
# _optv_with_wcfs_defaults returns optv prepended with default WCFS options taken from environment.
def
_optv_with_wcfs_defaults
(
optv
):
# -> optv
optv_defaults
=
os
.
environ
.
get
(
"WENDELIN_CORE_WCFS_OPTIONS"
,
""
).
split
()
return
tuple
(
optv_defaults
)
+
tuple
(
optv
)
# _start serves start and join.
@
func
def
_start
(
zurl
,
*
optv
):
# -> Server, fwcfs
mntpt
=
_mntpt_4zurl
(
zurl
)
optv
=
_optv_with_wcfs_defaults
(
optv
)
log
.
info
(
"wcfs: starting for %s ..."
,
zurl
)
optv_defaults
=
os
.
environ
.
get
(
"WENDELIN_CORE_WCFS_OPTIONS"
,
""
).
split
()
optv
=
tuple
(
optv_defaults
)
+
optv
# XXX errctx "wcfs: start"
# spawn wcfs and wait till filesystem-level access to it is ready
...
...
@@ -412,6 +417,7 @@ def __stop(wcsrv, ctx, _onstuck):
return
tctx
# unmount and wait for wcfs to exit
# kill wcfs and abort FUSE connection if clean unmount fails
def
_
():
if
wcsrv
.
_fuseabort
is
not
None
:
wcsrv
.
_fuseabort
.
close
()
...
...
@@ -494,7 +500,7 @@ def _mntpt_4zurl(zurl):
if
_mkdir_p
(
wcfsroot
):
os
.
chmod
(
wcfsroot
,
wcfsmode
)
else
:
# migration workaround for the situation when /
tmp
/wcfs was created by
# migration workaround for the situation when /
dev/shm
/wcfs was created by
# code that did not yet set sticky bit.
_
=
os
.
stat
(
wcfsroot
)
if
_
.
st_uid
==
os
.
getuid
():
...
...
@@ -651,8 +657,8 @@ def _ready(ch):
# serve(zurl, exec_=False).
def
serve
(
zurl
,
optv
,
exec_
=
False
,
_tstartingq
=
None
):
mntpt
=
_mntpt_4zurl
(
zurl
)
# XXX take $WENDELIN_CORE_WCFS_OPTIONS into account?
optv
=
_optv_with_wcfs_defaults
(
optv
)
log
.
info
(
"wcfs: serving %s ..."
,
zurl
)
# try opening .wcfs - it is an error if we can do it.
fwcfs
,
trylockstartf
=
_try_attach_wcsrv
(
mntpt
)
...
...
wcfs/client/_wczsync.pyx
View file @
c144b4a4
...
...
@@ -122,12 +122,11 @@ class _ZSync:
_zsync_releaseq.send(zsync.wconn)
"""
# .zconn dealloc -> wconn.close; release zsync.
def
on_zconn_dealloc
(
zsync
,
_
):
zsync
.
_release1
()
# DB.close
tells us that .zconn is shut down
-> wconn.close; release zsync.
# DB.close -> wconn.close; release zsync.
def
on_connection_shutdown
(
zsync
):
zsync
.
_release1
()
...
...
wcfs/client/_wczsync_test.py
View file @
c144b4a4
...
...
@@ -89,12 +89,12 @@ def test_zsync_zconn_gc():
db
,
zconn
,
wconn
=
_zsync_setup
(
zstor
)
defer
(
wconn
.
close
)
# del zconn
/db
-> zconn should disappear and ZSync should close wconn and wc
# del zconn -> zconn should disappear and ZSync should close wconn and wc
zconn_weak
=
weakref
.
ref
(
zconn
)
assert
zconn_weak
()
is
not
None
wc_njoin0
=
wconn
.
wc
.
_njoin
del
zconn
del
db
# NOTE db stays alive and not closed
gc
.
collect
()
assert
zconn_weak
()
is
None
_zsync_wclose_wg
.
wait
()
...
...
wcfs/wcfs_test.py
View file @
c144b4a4
...
...
@@ -248,7 +248,6 @@ def test_serve_after_crash():
assert
procmounts_lookup_wcfs
(
zurl
)
==
mntpt
# start_and_crash_wcfs starts wcfs and then kills it.
# it returns closed WCFS connection that was connected to the killed WCFS server.
def
start_and_crash_wcfs
(
zurl
,
mntpt
):
# -> WCFS
...
...
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