Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.libnetworkcache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
slapos.libnetworkcache
Commits
e207afea
Commit
e207afea
authored
May 13, 2013
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add correct timeout settings.
parent
35c0b582
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
slapos/libnetworkcache.py
slapos/libnetworkcache.py
+8
-5
No files found.
slapos/libnetworkcache.py
View file @
e207afea
...
@@ -28,8 +28,10 @@ import urlparse
...
@@ -28,8 +28,10 @@ import urlparse
# XXX: code between select/select_generic and upload/upload_generic should be
# XXX: code between select/select_generic and upload/upload_generic should be
# factored
# factored
# Upload/download timeout is one day
# Timeout here is about timeout to CONNECT to the server (socket initialization then server answers actual data), not to retrieve/send informations.
TIMEOUT
=
3600
*
24
# To be clear: it is NOT about uploading/downloading data, but about time to connect to the server, then time that server takes to start answering.
TIMEOUT
=
3600
class
NetworkcacheClient
(
object
):
class
NetworkcacheClient
(
object
):
'''
'''
...
@@ -275,7 +277,7 @@ class NetworkcacheClient(object):
...
@@ -275,7 +277,7 @@ class NetworkcacheClient(object):
sha_cache_url
=
os
.
path
.
join
(
self
.
shacache_url
,
sha512sum
)
sha_cache_url
=
os
.
path
.
join
(
self
.
shacache_url
,
sha512sum
)
request
=
urllib2
.
Request
(
url
=
sha_cache_url
,
data
=
None
,
request
=
urllib2
.
Request
(
url
=
sha_cache_url
,
data
=
None
,
headers
=
self
.
shadir_header_dict
)
headers
=
self
.
shadir_header_dict
)
return
urllib2
.
urlopen
(
request
)
return
urllib2
.
urlopen
(
request
,
timeout
=
TIMEOUT
)
def
select
(
self
,
key
):
def
select
(
self
,
key
):
''' Download a file from shacache by selecting the entry in shadir
''' Download a file from shacache by selecting the entry in shadir
...
@@ -284,7 +286,7 @@ class NetworkcacheClient(object):
...
@@ -284,7 +286,7 @@ class NetworkcacheClient(object):
url
=
os
.
path
.
join
(
self
.
shadir_url
,
key
)
url
=
os
.
path
.
join
(
self
.
shadir_url
,
key
)
request
=
urllib2
.
Request
(
url
=
url
,
data
=
None
,
request
=
urllib2
.
Request
(
url
=
url
,
data
=
None
,
headers
=
self
.
shadir_header_dict
)
headers
=
self
.
shadir_header_dict
)
data
=
urllib2
.
urlopen
(
request
).
read
()
data
=
urllib2
.
urlopen
(
request
,
timeout
=
TIMEOUT
).
read
()
# Filtering...
# Filtering...
try
:
try
:
data_list
=
json
.
loads
(
data
)
data_list
=
json
.
loads
(
data
)
...
@@ -323,7 +325,7 @@ class NetworkcacheClient(object):
...
@@ -323,7 +325,7 @@ class NetworkcacheClient(object):
url
=
os
.
path
.
join
(
self
.
shadir_url
,
key
)
url
=
os
.
path
.
join
(
self
.
shadir_url
,
key
)
request
=
urllib2
.
Request
(
url
=
url
,
data
=
None
,
request
=
urllib2
.
Request
(
url
=
url
,
data
=
None
,
headers
=
self
.
shadir_header_dict
)
headers
=
self
.
shadir_header_dict
)
data
=
urllib2
.
urlopen
(
request
).
read
()
data
=
urllib2
.
urlopen
(
request
,
timeout
=
TIMEOUT
).
read
()
try
:
try
:
data_list
=
json
.
loads
(
data
)
data_list
=
json
.
loads
(
data
)
except
Exception
:
except
Exception
:
...
@@ -417,3 +419,4 @@ class DirectoryNotFound(Exception):
...
@@ -417,3 +419,4 @@ class DirectoryNotFound(Exception):
class
UploadError
(
Exception
):
class
UploadError
(
Exception
):
pass
pass
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