Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pyfs
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pyfs
Commits
404935ed
Commit
404935ed
authored
Jun 19, 2009
by
rfkelly0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add default timeout to fuse.MountProcess.unmount, after which it will be forcibly terminated
parent
02ebf187
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
8 deletions
+29
-8
fs/expose/fuse/__init__.py
+16
-5
fs/tests/__init__.py
+6
-2
fs/tests/test_expose.py
+7
-1
No files found.
fs/expose/fuse/__init__.py
View file @
404935ed
...
...
@@ -380,6 +380,8 @@ class MountProcess(subprocess.Popen):
# just copy the relevant bits of the Popen interface. For now, this
# spawn-a-new-interpreter solution is the easiest to get up and running.
unmount_timeout
=
5
def
__init__
(
self
,
fs
,
path
,
fuse_opts
=
{},
nowait
=
False
,
**
kwds
):
self
.
path
=
path
if
nowait
or
kwds
.
get
(
"close_fds"
,
False
):
...
...
@@ -402,11 +404,21 @@ class MountProcess(subprocess.Popen):
def
unmount
(
self
):
"""Cleanly unmount the FUSE filesystem, terminating this subprocess."""
if
hasattr
(
self
,
"terminate"
):
self
.
terminate
()
else
:
self
.
terminate
()
tmr
=
threading
.
Timer
(
self
.
unmount_timeout
,
self
.
kill
)
tmr
.
start
()
self
.
wait
()
tmr
.
cancel
()
if
not
hasattr
(
subprocess
.
Popen
,
"terminate"
):
def
terminate
(
self
):
"""Gracefully terminate the subprocess."""
os
.
kill
(
self
.
pid
,
signal
.
SIGTERM
)
self
.
communicate
()
if
not
hasattr
(
subprocess
.
Popen
,
"kill"
):
def
kill
(
self
):
"""Forcibly terminate the subprocess."""
os
.
kill
(
self
.
pid
,
signal
.
SIGKILL
)
@staticmethod
def
_do_mount_nowait
(
data
):
...
...
@@ -443,7 +455,6 @@ class MountProcess(subprocess.Popen):
os
.
write
(
w
,
"E"
)
if
__name__
==
"__main__"
:
import
os
,
os
.
path
from
fs.tempfs
import
TempFS
...
...
fs/tests/__init__.py
View file @
404935ed
...
...
@@ -622,8 +622,12 @@ class ThreadingTestCases:
self
.
fs
.
copydir
(
"a"
,
"copy of a"
,
overwrite
=
True
)
# This should error out since we're not overwriting
self
.
assertRaises
(
DestinationExistsError
,
self
.
_runThreads
,
copydir
,
copydir
)
# This should run to completion and give a valid state
self
.
_runThreads
(
copydir_overwrite
,
copydir_overwrite
)
# This should run to completion and give a valid state, unless
# files get locked when written to.
try
:
self
.
_runThreads
(
copydir_overwrite
,
copydir_overwrite
)
except
ResourceLockedError
:
pass
self
.
assertTrue
(
self
.
fs
.
isdir
(
"copy of a"
))
self
.
assertTrue
(
self
.
fs
.
isdir
(
"copy of a/b"
))
self
.
assertEqual
(
self
.
fs
.
getcontents
(
"copy of a/b/parrot.txt"
),
"pining for the fiords"
)
...
...
fs/tests/test_expose.py
View file @
404935ed
...
...
@@ -112,7 +112,13 @@ class TestFUSE(unittest.TestCase,FSTestCases,ThreadingTestCases):
def
tearDown
(
self
):
self
.
mount_proc
.
unmount
()
self
.
temp_fs
.
close
()
try
:
self
.
temp_fs
.
close
()
except
OSError
:
# Sometimes FUSE hangs onto the mountpoint if mount_proc is
# forcibly killed. Shell out to fusermount to make sure.
fuse
.
unmount
(
self
.
mount_point
)
self
.
temp_fs
.
close
()
def
check
(
self
,
p
):
return
self
.
mounted_fs
.
exists
(
p
)
...
...
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