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
6a560274
Commit
6a560274
authored
Mar 03, 2009
by
rfkelly0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make S3FS pickleable
parent
5fa19265
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
2 deletions
+34
-2
fs/s3fs.py
+34
-2
No files found.
fs/s3fs.py
View file @
6a560274
...
@@ -59,10 +59,9 @@ class S3FS(FS):
...
@@ -59,10 +59,9 @@ class S3FS(FS):
by specifying the keyword 'separator' in the constructor.
by specifying the keyword 'separator' in the constructor.
"""
"""
self
.
_bucket_name
=
bucket
self
.
_bucket_name
=
bucket
self
.
_access_keys
=
(
aws_access_key
,
aws_secret_key
)
self
.
_separator
=
separator
self
.
_separator
=
separator
self
.
_key_sync_timeout
=
key_sync_timeout
self
.
_key_sync_timeout
=
key_sync_timeout
self
.
_s3conn
=
boto
.
s3
.
connection
.
S3Connection
(
aws_access_key
,
aws_secret_key
)
self
.
_s3bukt
=
self
.
_s3conn
.
create_bucket
(
bucket
)
# Normalise prefix to this form: path/to/files/
# Normalise prefix to this form: path/to/files/
while
prefix
.
startswith
(
separator
):
while
prefix
.
startswith
(
separator
):
prefix
=
prefix
[
1
:]
prefix
=
prefix
[
1
:]
...
@@ -71,6 +70,39 @@ class S3FS(FS):
...
@@ -71,6 +70,39 @@ class S3FS(FS):
self
.
_prefix
=
prefix
self
.
_prefix
=
prefix
FS
.
__init__
(
self
,
thread_syncronize
=
thread_syncronize
)
FS
.
__init__
(
self
,
thread_syncronize
=
thread_syncronize
)
# Make _s3conn and _s3bukt properties that are created on demand,
# since they cannot be stored during pickling.
def
_s3conn
(
self
):
try
:
return
self
.
__dict__
[
'_s3conn'
]
except
KeyError
:
c
=
boto
.
s3
.
connection
.
S3Connection
(
*
self
.
_access_keys
)
self
.
__dict__
[
'_s3conn'
]
=
c
return
c
_s3conn
=
property
(
_s3conn
)
def
_s3bukt
(
self
):
try
:
return
self
.
__dict__
[
'_s3bukt'
]
except
KeyError
:
b
=
self
.
_s3conn
.
create_bucket
(
self
.
_bucket_name
)
self
.
__dict__
[
'_s3bukt'
]
=
b
return
b
_s3bukt
=
property
(
_s3bukt
)
def
__getstate__
(
self
):
state
=
super
(
S3FS
,
self
)
.
__getstate__
()
try
:
del
state
[
'_s3conn'
]
except
KeyError
:
pass
try
:
del
state
[
'_s3bukt'
]
except
KeyError
:
pass
return
state
def
__str__
(
self
):
def
__str__
(
self
):
return
'<S3FS:
%
s:
%
s>'
%
(
self
.
_bucket_name
,
self
.
_prefix
)
return
'<S3FS:
%
s:
%
s>'
%
(
self
.
_bucket_name
,
self
.
_prefix
)
...
...
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