Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
synnefo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
itminedu
synnefo
Commits
7aa4f62f
Commit
7aa4f62f
authored
Apr 04, 2013
by
Ilias Tsitsimpis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
astakosclient: Use objpool version 0.2
parent
6061997d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
13 deletions
+18
-13
snf-astakos-client/astakosclient/__init__.py
snf-astakos-client/astakosclient/__init__.py
+5
-7
snf-astakos-client/astakosclient/utils.py
snf-astakos-client/astakosclient/utils.py
+12
-5
snf-astakos-client/setup.py
snf-astakos-client/setup.py
+1
-1
No files found.
snf-astakos-client/astakosclient/__init__.py
View file @
7aa4f62f
...
...
@@ -141,17 +141,15 @@ class AstakosClient():
kwargs
[
'headers'
].
setdefault
(
'content-length'
,
len
(
body
)
if
body
else
0
)
# Get the connection object
conn
=
self
.
conn_class
(
self
.
netloc
)
# Send request
try
:
(
data
,
status
)
=
_do_request
(
conn
,
method
,
request_path
,
**
kwargs
)
# Get the connection object
with
self
.
conn_class
(
self
.
netloc
)
as
conn
:
# Send request
(
data
,
status
)
=
\
_do_request
(
conn
,
method
,
request_path
,
**
kwargs
)
except
Exception
as
err
:
self
.
logger
.
error
(
"Failed to send request: %s"
%
repr
(
err
))
raise
AstakosClientException
(
str
(
err
))
finally
:
conn
.
close
()
# Return
self
.
logger
.
debug
(
"Request returned with status %s"
%
status
)
...
...
snf-astakos-client/astakosclient/utils.py
View file @
7aa4f62f
...
...
@@ -31,9 +31,10 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
import
httplib
from
httplib
import
HTTPConnection
,
HTTPSConnection
from
contextlib
import
closing
import
objpool.http
from
objpool.http
import
PooledHTTPConnection
from
astakosclient.errors
import
AstakosClientException
...
...
@@ -59,18 +60,24 @@ def retry(func):
def
scheme_to_class
(
scheme
,
use_pool
,
pool_size
):
"""Return the appropriate conn class for given scheme"""
def
_objpool
(
netloc
):
return
objpool
.
http
.
get_http_c
onnection
(
return
PooledHTTPC
onnection
(
netloc
=
netloc
,
scheme
=
scheme
,
pool_size
=
pool_size
)
def
_http_connection
(
netloc
):
return
closing
(
HTTPConnection
(
netloc
))
def
_https_connection
(
netloc
):
return
closing
(
HTTPSConnection
(
netloc
))
if
scheme
==
"http"
:
if
use_pool
:
return
_objpool
else
:
return
httplib
.
HTTPC
onnection
return
_http_c
onnection
elif
scheme
==
"https"
:
if
use_pool
:
return
_objpool
else
:
return
httplib
.
HTTPSC
onnection
return
_https_c
onnection
else
:
return
None
snf-astakos-client/setup.py
View file @
7aa4f62f
...
...
@@ -59,7 +59,7 @@ CLASSIFIERS = []
# Package requirements
INSTALL_REQUIRES
=
[
"objpool"
,
"objpool
>= 0.2
"
,
"simplejson"
]
...
...
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