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
359377ac
Commit
359377ac
authored
Jul 21, 2009
by
rfkelly0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add explicit close() method for ConnectionManagerFS
parent
5af99561
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
2 deletions
+22
-2
fs/remote.py
+16
-1
fs/tests/__init__.py
+2
-1
fs/wrapfs.py
+4
-0
No files found.
fs/remote.py
View file @
359377ac
...
...
@@ -162,6 +162,7 @@ class ConnectionManagerFS(WrapFS):
self
.
_fskwds
=
{}
self
.
_connection_cond
=
threading
.
Condition
()
self
.
_poll_thread
=
None
self
.
_poll_sleeper
=
threading
.
Event
()
self
.
connected
=
connected
@property
...
...
@@ -183,12 +184,14 @@ class ConnectionManagerFS(WrapFS):
def
__getstate__
(
self
):
state
=
super
(
ConnectionManagerFS
,
self
)
.
__getstate__
()
del
state
[
"_connection_cond"
]
del
state
[
"_poll_sleeper"
]
state
[
"_poll_thread"
]
=
None
return
state
def
__setstate__
(
self
,
state
):
super
(
ConnectionManagerFS
,
self
)
.
__setstate__
(
state
)
self
.
_connection_cond
=
threading
.
Condition
()
self
.
_poll_sleeper
=
threading
.
Event
()
def
wait_for_connection
(
self
,
timeout
=
None
):
self
.
_connection_cond
.
acquire
()
...
...
@@ -205,7 +208,8 @@ class ConnectionManagerFS(WrapFS):
try
:
self
.
wrapped_fs
.
isdir
(
""
)
except
RemoteConnectionError
:
time
.
sleep
(
self
.
poll_interval
)
self
.
_poll_sleeper
.
wait
(
self
.
poll_interval
)
self
.
_poll_sleeper
.
clear
()
continue
except
FSError
:
break
...
...
@@ -217,6 +221,17 @@ class ConnectionManagerFS(WrapFS):
self
.
_connection_cond
.
notifyAll
()
self
.
_connection_cond
.
release
()
def
close
(
self
):
try
:
self
.
wrapped_fs
.
close
()
except
(
RemoteConnectionError
,
AttributeError
):
pass
if
self
.
_poll_thread
:
self
.
connected
=
True
self
.
_poll_sleeper
.
set
()
self
.
_poll_thread
.
join
()
self
.
_poll_thread
=
None
def
_ConnectionManagerFS_method_wrapper
(
func
):
"""Method wrapper for ConnectionManagerFS.
...
...
fs/tests/__init__.py
View file @
359377ac
...
...
@@ -470,7 +470,8 @@ class FSTestCases:
"""Generate predictable-but-randomy binary content."""
r
=
random
.
Random
(
0
)
for
i
in
xrange
(
num_chunks
):
yield
""
.
join
(
chr
(
r
.
randint
(
0
,
255
))
for
j
in
xrange
(
chunk_size
))
c
=
""
.
join
(
chr
(
r
.
randint
(
0
,
255
))
for
j
in
xrange
(
chunk_size
/
8
))
yield
c
*
8
f
=
self
.
fs
.
open
(
"bigfile"
,
"wb"
)
try
:
for
chunk
in
chunk_stream
():
...
...
fs/wrapfs.py
View file @
359377ac
...
...
@@ -125,6 +125,10 @@ class WrapFS(FS):
return
self
.
_file_wrap
(
f
,
mode
)
@rewrite_errors
def
setcontents
(
self
,
path
,
contents
):
self
.
wrapped_fs
.
setcontents
(
self
.
_encode
(
path
),
contents
)
@rewrite_errors
def
exists
(
self
,
path
):
return
self
.
wrapped_fs
.
exists
(
self
.
_encode
(
path
))
...
...
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