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
db7fa9fd
Commit
db7fa9fd
authored
May 05, 2011
by
rfkelly0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix gc-related errors in RemoteFileBuffer tests
parent
dd808d70
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
fs/remote.py
+10
-6
fs/tests/test_remote.py
+8
-0
No files found.
fs/remote.py
View file @
db7fa9fd
...
...
@@ -592,6 +592,8 @@ class CacheFSMixin(FS):
return
True
except
StopIteration
:
pass
except
RuntimeError
:
pass
try
:
info
=
self
.
getinfo
(
path
)
except
ResourceNotFoundError
:
...
...
@@ -605,6 +607,8 @@ class CacheFSMixin(FS):
return
False
except
StopIteration
:
pass
except
RuntimeError
:
pass
try
:
info
=
self
.
getinfo
(
path
)
except
ResourceNotFoundError
:
...
...
@@ -640,7 +644,7 @@ class CacheFSMixin(FS):
ci
=
CachedInfo
(
info
)
self
.
__set_cached_info
(
cpath
,
ci
)
to_del
=
[]
for
nm
in
self
.
__cache
.
iter
names
(
path
):
for
nm
in
self
.
__cache
.
names
(
path
):
if
nm
not
in
names
:
to_del
.
append
(
nm
)
for
nm
in
to_del
:
...
...
@@ -697,33 +701,33 @@ class CacheFSMixin(FS):
def
rename
(
self
,
src
,
dst
):
super
(
CacheFSMixin
,
self
)
.
rename
(
src
,
dst
)
with
self
.
__cache_lock
:
for
(
subpath
,
ci
)
in
self
.
__cache
.
ite
rite
ms
(
src
):
for
(
subpath
,
ci
)
in
self
.
__cache
.
items
(
src
):
self
.
__cache
[
pathjoin
(
dst
,
subpath
)]
=
ci
.
clone
()
self
.
__cache
.
clear
(
src
)
def
copy
(
self
,
src
,
dst
,
**
kwds
):
super
(
CacheFSMixin
,
self
)
.
copy
(
src
,
dst
,
**
kwds
)
with
self
.
__cache_lock
:
for
(
subpath
,
ci
)
in
self
.
__cache
.
ite
rite
ms
(
src
):
for
(
subpath
,
ci
)
in
self
.
__cache
.
items
(
src
):
self
.
__cache
[
pathjoin
(
dst
,
subpath
)]
=
ci
.
clone
()
def
copydir
(
self
,
src
,
dst
,
**
kwds
):
super
(
CacheFSMixin
,
self
)
.
copydir
(
src
,
dst
,
**
kwds
)
with
self
.
__cache_lock
:
for
(
subpath
,
ci
)
in
self
.
__cache
.
ite
rite
ms
(
src
):
for
(
subpath
,
ci
)
in
self
.
__cache
.
items
(
src
):
self
.
__cache
[
pathjoin
(
dst
,
subpath
)]
=
ci
.
clone
()
def
move
(
self
,
src
,
dst
,
**
kwds
):
super
(
CacheFSMixin
,
self
)
.
move
(
src
,
dst
,
**
kwds
)
with
self
.
__cache_lock
:
for
(
subpath
,
ci
)
in
self
.
__cache
.
ite
rite
ms
(
src
):
for
(
subpath
,
ci
)
in
self
.
__cache
.
items
(
src
):
self
.
__cache
[
pathjoin
(
dst
,
subpath
)]
=
ci
.
clone
()
self
.
__cache
.
clear
(
src
)
def
movedir
(
self
,
src
,
dst
,
**
kwds
):
super
(
CacheFSMixin
,
self
)
.
movedir
(
src
,
dst
,
**
kwds
)
with
self
.
__cache_lock
:
for
(
subpath
,
ci
)
in
self
.
__cache
.
ite
rite
ms
(
src
):
for
(
subpath
,
ci
)
in
self
.
__cache
.
items
(
src
):
self
.
__cache
[
pathjoin
(
dst
,
subpath
)]
=
ci
.
clone
()
self
.
__cache
.
clear
(
src
)
...
...
fs/tests/test_remote.py
View file @
db7fa9fd
...
...
@@ -77,6 +77,7 @@ class TestRemoteFileBuffer(unittest.TestCase, FSTestCases, ThreadingTestCases):
def
tearDown
(
self
):
self
.
fs
.
close
()
self
.
fakeOff
()
def
fake_setcontents
(
self
,
path
,
content
=
''
,
chunk_size
=
16
*
1024
):
''' Fake replacement for RemoteTempFS setcontents() '''
...
...
@@ -139,6 +140,7 @@ class TestRemoteFileBuffer(unittest.TestCase, FSTestCases, ThreadingTestCases):
f
.
flush
()
# We are on the end of file (and buffer not serve anything anymore)
self
.
assertEquals
(
f
.
read
(),
''
)
f
.
close
()
self
.
fakeOn
()
...
...
@@ -148,6 +150,8 @@ class TestRemoteFileBuffer(unittest.TestCase, FSTestCases, ThreadingTestCases):
self
.
assertEquals
(
f
.
read
(),
contents
[:
-
5
]
+
u'1234567890'
)
f
.
close
()
self
.
fakeOff
()
def
test_writeonflush
(
self
):
'''
Test 'write_on_flush' switch of RemoteFileBuffer.
...
...
@@ -161,6 +165,9 @@ class TestRemoteFileBuffer(unittest.TestCase, FSTestCases, ThreadingTestCases):
self
.
assertRaises
(
self
.
FakeException
,
f
.
flush
)
f
.
write
(
'Second sample text'
)
self
.
assertRaises
(
self
.
FakeException
,
f
.
close
)
self
.
fakeOff
()
f
.
close
()
self
.
fakeOn
()
f
=
self
.
fs
.
open
(
'test.txt'
,
'wb'
,
write_on_flush
=
False
)
f
.
write
(
'Sample text'
)
...
...
@@ -168,6 +175,7 @@ class TestRemoteFileBuffer(unittest.TestCase, FSTestCases, ThreadingTestCases):
f
.
flush
()
f
.
write
(
'Second sample text'
)
self
.
assertRaises
(
self
.
FakeException
,
f
.
close
)
self
.
fakeOff
()
def
test_flush_and_continue
(
self
):
'''
...
...
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