Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Show more breadcrumbs
AURA
engine
Commits
c05fefa7
Verified
Commit
c05fefa7
authored
5 months ago
by
Ole Binder
Browse files
Options
Downloads
Patches
Plain Diff
Fix: move exception handling from read to send.
#153
parent
4273bb7c
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!51
Fix broken pipe #153
Pipeline
#8740
passed
5 months ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/aura_engine/core/client.py
+28
-33
28 additions, 33 deletions
src/aura_engine/core/client.py
with
28 additions
and
33 deletions
src/aura_engine/core/client.py
+
28
−
33
View file @
c05fefa7
...
...
@@ -258,6 +258,10 @@ class CoreConnection:
def
open
(
self
):
"""
Connect to Liquidsoap socket.
Raises:
CoreConnectionError: Raised when there is a connection or communication
Error.
"""
try
:
self
.
socket
=
socket
.
socket
(
socket
.
AF_UNIX
,
socket
.
SOCK_STREAM
)
...
...
@@ -308,9 +312,14 @@ class CoreConnection:
try
:
self
.
socket
.
sendall
(
command
.
encode
())
result
=
self
.
read
()
except
BrokenPipeError
:
except
BrokenPipeError
as
broken_pipe
:
msg
=
"
Broken Pipe while sending command
"
self
.
logger
.
info
(
SU
.
pink
(
msg
))
self
.
logger
.
error
(
SU
.
red
(
msg
),
broken_pipe
)
self
.
connected
=
False
raise
CoreConnectionError
(
msg
)
except
TimeoutError
as
timeout_error
:
msg
=
"
Socket timeout while reading
"
self
.
logger
.
error
(
SU
.
red
(
msg
),
timeout_error
)
self
.
connected
=
False
raise
CoreConnectionError
(
msg
)
except
Exception
as
e
:
...
...
@@ -336,19 +345,12 @@ class CoreConnection:
"""
data
=
""
try
:
self
.
socket
.
settimeout
(
timeout
)
while
True
:
data
+=
self
.
socket
.
recv
(
1
).
decode
(
CoreConnection
.
ENCODING
)
if
data
.
find
(
"
END
\r\n
"
)
!=
-
1
or
data
.
find
(
"
Bye!
\r\n
"
)
!=
-
1
:
data
.
replace
(
"
END
\r\n
"
,
""
)
break
except
TimeoutError
as
timeout_error
:
msg
=
f
"
Socket timeout after
{
timeout
}
seconds while reading
"
self
.
logger
.
warning
(
SU
.
yellow
(
msg
),
timeout_error
)
except
Exception
as
e
:
msg
=
"
Unknown error while socket.read_all()
"
self
.
logger
.
error
(
SU
.
red
(
msg
),
e
)
self
.
socket
.
settimeout
(
timeout
)
while
True
:
data
+=
self
.
socket
.
recv
(
1
).
decode
(
CoreConnection
.
ENCODING
)
if
data
.
find
(
"
END
\r\n
"
)
!=
-
1
or
data
.
find
(
"
Bye!
\r\n
"
)
!=
-
1
:
data
.
replace
(
"
END
\r\n
"
,
""
)
break
return
data
@private
...
...
@@ -360,25 +362,18 @@ class CoreConnection:
str: message read from socket
@private
"""
if
self
.
connected
:
ret
=
self
.
read_all
().
splitlines
()
try
:
last
=
ret
.
pop
()
if
last
!=
"
Bye!
"
:
if
len
(
ret
)
>
1
:
self
.
message
=
str
.
join
(
"
-
"
,
ret
)
elif
len
(
ret
)
==
1
:
self
.
message
=
ret
[
0
]
else
:
self
.
message
=
last
except
Exception
as
e
:
msg
=
"
Unknown error while socket.read()
"
self
.
logger
.
error
(
SU
.
red
(
msg
),
e
)
return
self
.
message
# FIXME: return str if no tests depend on this None.
return
None
ret
=
self
.
read_all
().
splitlines
()
last
=
ret
.
pop
()
if
last
!=
"
Bye!
"
:
if
len
(
ret
)
>
1
:
self
.
message
=
str
.
join
(
"
-
"
,
ret
)
elif
len
(
ret
)
==
1
:
self
.
message
=
ret
[
0
]
else
:
self
.
message
=
last
return
self
.
message
class
CoreConnectionError
(
Exception
):
...
...
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