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
34278cc9
Commit
34278cc9
authored
Mar 02, 2009
by
rfkelly0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
basic support for pickling FS instances
parent
19c56179
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
fs/base.py
+21
-0
fs/tempfs.py
+2
-3
No files found.
fs/base.py
View file @
34278cc9
...
@@ -221,6 +221,27 @@ class FS(object):
...
@@ -221,6 +221,27 @@ class FS(object):
else
:
else
:
self
.
_lock
=
dummy_threading
.
RLock
()
self
.
_lock
=
dummy_threading
.
RLock
()
def
__getstate__
(
self
):
state
=
self
.
__dict__
.
copy
()
lock
=
state
.
get
(
"_lock"
,
None
)
if
lock
is
not
None
:
if
isinstance
(
lock
,
threading
.
_RLock
):
state
[
"_lock"
]
=
True
else
:
state
[
"_lock"
]
=
False
return
state
def
__setstate__
(
self
,
state
):
for
(
k
,
v
)
in
state
.
iteritems
():
print
(
k
,
v
)
self
.
__dict__
[
k
]
=
v
lock
=
state
.
get
(
"_lock"
,
None
)
if
lock
is
not
None
:
if
lock
:
self
.
_lock
=
threading
.
RLock
()
else
:
self
.
_lock
=
dummy_threading
.
RLock
()
def
_resolve
(
self
,
pathname
):
def
_resolve
(
self
,
pathname
):
resolved_path
=
resolvepath
(
pathname
)
resolved_path
=
resolvepath
(
pathname
)
return
resolved_path
return
resolved_path
...
...
fs/tempfs.py
View file @
34278cc9
...
@@ -33,7 +33,7 @@ class TempFS(OSFS):
...
@@ -33,7 +33,7 @@ class TempFS(OSFS):
This will be called automatically when the object is cleaned up by Python.
This will be called automatically when the object is cleaned up by Python.
Note that once this method has been called, the FS object may no longer be used."""
Note that once this method has been called, the FS object may no longer be used."""
if
not
self
.
_cleaned
:
if
not
self
.
_cleaned
and
self
.
exists
(
"/"
)
:
self
.
_lock
.
acquire
()
self
.
_lock
.
acquire
()
try
:
try
:
rmtree
(
self
.
_temp_dir
)
rmtree
(
self
.
_temp_dir
)
...
@@ -47,4 +47,4 @@ class TempFS(OSFS):
...
@@ -47,4 +47,4 @@ class TempFS(OSFS):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
tfs
=
TempFS
()
tfs
=
TempFS
()
print
tfs
print
tfs
\ No newline at end of file
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