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
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sébastien DA ROCHA
sakia
Commits
c949ffe6
Commit
c949ffe6
authored
7 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Silence unworrying exceptions
parent
aed52c33
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sakia/data/connectors/node.py
+27
-16
27 additions, 16 deletions
src/sakia/data/connectors/node.py
src/sakia/main.py
+26
-2
26 additions, 2 deletions
src/sakia/main.py
with
53 additions
and
18 deletions
src/sakia/data/connectors/node.py
+
27
−
16
View file @
c949ffe6
...
...
@@ -113,10 +113,10 @@ class NodeConnector(QObject):
else
:
raise
except
(
ClientError
,
gaierror
,
TimeoutError
,
ConnectionRefusedError
,
ValueError
)
as
e
:
self
.
_logger
.
debug
(
"
{
0
}
"
.
format
(
str
(
e
)))
self
.
_logger
.
debug
(
"
{
:}:{:
}
"
.
format
(
str
(
e
.
__class__
.
__name__
),
str
(
e
)))
self
.
change_state_and_emit
(
Node
.
OFFLINE
)
except
jsonschema
.
ValidationError
as
e
:
self
.
_logger
.
debug
(
str
(
e
))
self
.
_logger
.
debug
(
"
{:}:{:}
"
.
format
(
str
(
e
.
__class__
.
__name__
),
str
(
e
)
))
self
.
change_state_and_emit
(
Node
.
CORRUPTED
)
except
RuntimeError
:
if
self
.
session
.
closed
:
...
...
@@ -187,8 +187,7 @@ class NodeConnector(QObject):
self
.
_logger
.
debug
(
"
{0} : {1}
"
.
format
(
str
(
e
),
self
.
node
.
pubkey
[:
5
]))
self
.
change_state_and_emit
(
Node
.
OFFLINE
)
except
jsonschema
.
ValidationError
as
e
:
self
.
_logger
.
debug
(
str
(
e
))
self
.
_logger
.
debug
(
"
Validation error
"
)
self
.
_logger
.
debug
(
"
{:}:{:}
"
.
format
(
str
(
e
.
__class__
.
__name__
),
str
(
e
)))
self
.
change_state_and_emit
(
Node
.
CORRUPTED
)
except
RuntimeError
:
if
self
.
session
.
closed
:
...
...
@@ -219,6 +218,9 @@ class NodeConnector(QObject):
else
:
self
.
change_state_and_emit
(
Node
.
CORRUPTED
)
self
.
_logger
.
debug
(
"
Error in block reply : {0}
"
.
format
(
str
(
e
)))
else
:
if
self
.
session
.
closed
:
pass
else
:
self
.
_logger
.
debug
(
"
Could not connect to any BMA endpoint
"
)
self
.
change_state_and_emit
(
Node
.
OFFLINE
)
...
...
@@ -257,6 +259,9 @@ class NodeConnector(QObject):
self
.
_logger
.
debug
(
"
Changed block {0} -> {1}
"
.
format
(
self
.
node
.
current_buid
.
number
,
block_data
[
'
number
'
]))
self
.
changed
.
emit
()
else
:
if
self
.
session
.
closed
:
pass
else
:
self
.
_logger
.
debug
(
"
Could not connect to any BMA endpoint
"
)
self
.
change_state_and_emit
(
Node
.
OFFLINE
)
...
...
@@ -282,6 +287,9 @@ class NodeConnector(QObject):
except
errors
.
DuniterError
as
e
:
self
.
_logger
.
debug
(
"
Error in summary : {:}
"
.
format
(
str
(
e
)))
self
.
change_state_and_emit
(
Node
.
OFFLINE
)
else
:
if
self
.
session
.
closed
:
pass
else
:
self
.
_logger
.
debug
(
"
Could not connect to any BMA endpoint
"
)
self
.
change_state_and_emit
(
Node
.
OFFLINE
)
...
...
@@ -314,10 +322,10 @@ class NodeConnector(QObject):
.
format
(
type
(
e
).
__name__
,
str
(
e
)))
await
self
.
request_peers
()
except
(
ClientError
,
gaierror
,
TimeoutError
)
as
e
:
self
.
_logger
.
debug
(
"
{
0
}
"
.
format
(
str
(
e
)))
self
.
_logger
.
debug
(
"
{
:}:{:
}
"
.
format
(
str
(
e
.
__class__
.
__name__
),
str
(
e
)))
self
.
change_state_and_emit
(
Node
.
OFFLINE
)
except
jsonschema
.
ValidationError
as
e
:
self
.
_logger
.
debug
(
str
(
e
))
self
.
_logger
.
debug
(
"
{:}:{:}
"
.
format
(
str
(
e
.
__class__
.
__name__
),
str
(
e
)
))
self
.
change_state_and_emit
(
Node
.
CORRUPTED
)
except
RuntimeError
:
if
self
.
session
.
closed
:
...
...
@@ -359,7 +367,7 @@ class NodeConnector(QObject):
if
e
.
ucode
==
2012
:
# Since with multinodes, peers or not the same on all nodes, sometimes this request results
# in peer not found error
self
.
_logger
.
debug
(
str
(
e
))
self
.
_logger
.
debug
(
"
{:}:{:}
"
.
format
(
str
(
e
.
__class__
.
__name__
),
str
(
e
)
))
else
:
self
.
change_state_and_emit
(
Node
.
OFFLINE
)
self
.
_logger
.
debug
(
"
Incorrect peer data in {leaf} : {err}
"
.
format
(
leaf
=
leaf_hash
,
err
=
str
(
e
)))
...
...
@@ -370,6 +378,9 @@ class NodeConnector(QObject):
except
errors
.
DuniterError
as
e
:
self
.
_logger
.
debug
(
"
Error in peers reply : {0}
"
.
format
(
str
(
e
)))
self
.
change_state_and_emit
(
Node
.
OFFLINE
)
else
:
if
self
.
session
.
closed
:
pass
else
:
self
.
_logger
.
debug
(
"
Could not connect to any BMA endpoint
"
)
self
.
change_state_and_emit
(
Node
.
OFFLINE
)
...
...
@@ -382,7 +393,7 @@ class NodeConnector(QObject):
peer_doc
=
Peer
.
from_signed_raw
(
str_doc
)
self
.
neighbour_found
.
emit
(
peer_doc
)
except
MalformedDocumentError
as
e
:
self
.
_logger
.
debug
(
str
(
e
))
self
.
_logger
.
debug
(
"
{:}:{:}
"
.
format
(
str
(
e
.
__class__
.
__name__
),
str
(
e
)
))
else
:
self
.
_logger
.
debug
(
"
Incorrect leaf reply
"
)
...
...
This diff is collapsed.
Click to expand it.
src/sakia/main.py
+
26
−
2
View file @
c949ffe6
...
...
@@ -18,6 +18,30 @@ from sakia.gui.preferences import PreferencesDialog
from
sakia.gui.widgets
import
QAsyncMessageBox
def
exit_exception_handler
(
loop
,
context
):
"""
An exception handler which prints only on debug (used when exiting)
:param loop: the asyncio loop
:param context: the exception context
"""
logging
.
debug
(
'
Exception handler executing
'
)
message
=
context
.
get
(
'
message
'
)
if
not
message
:
message
=
'
Unhandled exception in event loop
'
try
:
exception
=
context
[
'
exception
'
]
except
KeyError
:
exc_info
=
False
else
:
exc_info
=
(
type
(
exception
),
exception
,
exception
.
__traceback__
)
logging
.
debug
(
"
An unhandled exception occured : {0}
"
.
format
(
message
),
exc_info
=
exc_info
)
def
async_exception_handler
(
loop
,
context
):
"""
An exception handler which exits the program if the exception
...
...
@@ -85,7 +109,7 @@ def main():
sys
.
excepthook
=
exception_handler
sakia
.
setStyle
(
'
Fusion
'
)
#
sakia.setStyle('Fusion')
loop
=
QSelectorEventLoop
(
sakia
)
loop
.
set_exception_handler
(
async_exception_handler
)
#loop.set_debug(True)
...
...
@@ -131,7 +155,7 @@ def main():
window
=
MainWindowController
.
startup
(
app
)
loop
.
run_forever
()
try
:
loop
.
set_exception_handler
(
None
)
loop
.
set_exception_handler
(
exit_exception_handler
)
loop
.
run_until_complete
(
app
.
stop_current_profile
())
logging
.
debug
(
"
Application stopped
"
)
except
asyncio
.
CancelledError
:
...
...
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