Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sakia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
clients
python
sakia
Commits
d97cbdee
Commit
d97cbdee
authored
8 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Compatibility with new conn_handler method
parent
88f04278
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sakia/data/connectors/bma.py
+5
-5
5 additions, 5 deletions
src/sakia/data/connectors/bma.py
src/sakia/data/connectors/node.py
+6
-6
6 additions, 6 deletions
src/sakia/data/connectors/node.py
with
11 additions
and
11 deletions
src/sakia/data/connectors/bma.py
+
5
−
5
View file @
d97cbdee
...
...
@@ -186,8 +186,8 @@ class BmaConnector:
endpoint
=
random
.
choice
(
endpoints
)
self
.
_logger
.
debug
(
"
Requesting {0} on endpoint {1}
"
.
format
(
str
(
request
.
__name__
),
str
(
endpoint
)))
futures
.
append
(
request
(
endpoint
.
conn_handler
(
session
,
proxy
=
self
.
_user_parameters
.
proxy
()),
futures
.
append
(
request
(
next
(
endpoint
.
conn_handler
(
session
,
proxy
=
self
.
_user_parameters
.
proxy
())
)
,
**
req_args
))
except
StopIteration
:
# When no more node is available, we go out of the while loop
...
...
@@ -234,7 +234,7 @@ class BmaConnector:
try
:
self
.
_logger
.
debug
(
"
Requesting {0} on endpoint {1}
"
.
format
(
str
(
request
.
__name__
),
str
(
endpoint
)))
async
with
aiohttp
.
ClientSession
()
as
session
:
json_data
=
await
request
(
endpoint
.
conn_handler
(
session
),
**
req_args
)
json_data
=
await
request
(
next
(
endpoint
.
conn_handler
(
session
),
**
req_args
)
)
return
json_data
except
errors
.
DuniterError
as
e
:
if
e
.
ucode
==
errors
.
HTTP_LIMITATION
:
...
...
@@ -283,8 +283,8 @@ class BmaConnector:
with
aiohttp
.
ClientSession
()
as
session
:
for
endpoint
in
endpoints
:
self
.
_logger
.
debug
(
"
Trying to connect to :
"
+
str
(
endpoint
))
reply
=
asyncio
.
ensure_future
(
request
(
endpoint
.
conn_handler
(
session
,
proxy
=
self
.
_user_parameters
.
proxy
()),
reply
=
asyncio
.
ensure_future
(
request
(
next
(
endpoint
.
conn_handler
(
session
,
proxy
=
self
.
_user_parameters
.
proxy
())
)
,
**
req_args
))
replies
.
append
(
reply
)
...
...
This diff is collapsed.
Click to expand it.
src/sakia/data/connectors/node.py
+
6
−
6
View file @
d97cbdee
...
...
@@ -95,7 +95,7 @@ class NodeConnector(QObject):
async
def
safe_request
(
self
,
endpoint
,
request
,
proxy
,
req_args
=
{}):
try
:
conn_handler
=
endpoint
.
conn_handler
(
self
.
session
,
proxy
=
proxy
)
conn_handler
=
next
(
endpoint
.
conn_handler
(
self
.
session
,
proxy
=
proxy
)
)
data
=
await
request
(
conn_handler
,
**
req_args
)
return
data
except
(
ClientError
,
gaierror
,
TimeoutError
,
ConnectionRefusedError
,
DisconnectedError
,
ValueError
)
as
e
:
...
...
@@ -155,7 +155,7 @@ class NodeConnector(QObject):
for
endpoint
in
[
e
for
e
in
self
.
node
.
endpoints
if
isinstance
(
e
,
BMAEndpoint
)]:
if
not
self
.
_connected
[
'
block
'
]:
try
:
conn_handler
=
endpoint
.
conn_handler
(
self
.
session
,
proxy
=
self
.
_user_parameters
.
proxy
())
conn_handler
=
next
(
endpoint
.
conn_handler
(
self
.
session
,
proxy
=
self
.
_user_parameters
.
proxy
())
)
ws_connection
=
bma
.
ws
.
block
(
conn_handler
)
async
with
ws_connection
as
ws
:
self
.
_connected
[
'
block
'
]
=
True
...
...
@@ -222,8 +222,8 @@ class NodeConnector(QObject):
self
.
node
.
state
=
Node
.
ONLINE
if
not
self
.
node
.
current_buid
or
self
.
node
.
current_buid
.
sha_hash
!=
block_data
[
'
hash
'
]:
for
endpoint
in
[
e
for
e
in
self
.
node
.
endpoints
if
isinstance
(
e
,
BMAEndpoint
)]:
conn_handler
=
endpoint
.
conn_handler
(
self
.
session
,
proxy
=
self
.
_user_parameters
.
proxy
())
conn_handler
=
next
(
endpoint
.
conn_handler
(
self
.
session
,
proxy
=
self
.
_user_parameters
.
proxy
())
)
self
.
_logger
.
debug
(
"
Requesting {0}
"
.
format
(
conn_handler
))
try
:
previous_block
=
await
self
.
safe_request
(
endpoint
,
bma
.
blockchain
.
block
,
...
...
@@ -285,8 +285,8 @@ class NodeConnector(QObject):
for
endpoint
in
[
e
for
e
in
self
.
node
.
endpoints
if
isinstance
(
e
,
BMAEndpoint
)]:
if
not
self
.
_connected
[
'
peer
'
]:
try
:
conn_handler
=
endpoint
.
conn_handler
(
self
.
session
,
proxy
=
self
.
_user_parameters
.
proxy
())
conn_handler
=
next
(
endpoint
.
conn_handler
(
self
.
session
,
proxy
=
self
.
_user_parameters
.
proxy
())
)
ws_connection
=
bma
.
ws
.
peer
(
conn_handler
)
async
with
ws_connection
as
ws
:
self
.
_connected
[
'
peer
'
]
=
True
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment