Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lu Xu
slapos.toolbox
Commits
7a0abee9
Commit
7a0abee9
authored
Oct 01, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pubsub notifier: handle timeout and other connection errors
parent
2047bfd8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
+13
-8
slapos/pubsub/notifier.py
slapos/pubsub/notifier.py
+13
-8
No files found.
slapos/pubsub/notifier.py
View file @
7a0abee9
...
...
@@ -9,6 +9,7 @@ import socket
import
subprocess
import
sys
import
time
import
traceback
import
urllib2
import
urlparse
import
uuid
...
...
@@ -80,14 +81,18 @@ def main():
notification_port
=
socket
.
getservbyname
(
notification_url
.
scheme
)
headers
=
{
'Content-Type'
:
feed
.
info
().
getheader
(
'Content-Type'
)}
notification
=
httplib
.
HTTPConnection
(
notification_url
.
hostname
,
notification_port
)
notification
.
request
(
'POST'
,
notification_url
.
path
,
body
,
headers
)
response
=
notification
.
getresponse
()
if
not
(
200
<=
response
.
status
<
300
):
sys
.
stderr
.
write
(
"The remote server at %s didn't send a successful reponse.
\
n
"
%
notif_url
)
sys
.
stderr
.
write
(
"Its response was %r
\
n
"
%
response
.
reason
)
try
:
notification
=
httplib
.
HTTPConnection
(
notification_url
.
hostname
,
notification_port
)
notification
.
request
(
'POST'
,
notification_url
.
path
,
body
,
headers
)
response
=
notification
.
getresponse
()
if
not
(
200
<=
response
.
status
<
300
):
sys
.
stderr
.
write
(
"The remote server at %s didn't send a successful reponse.
\
n
"
%
notif_url
)
sys
.
stderr
.
write
(
"Its response was %r
\
n
"
%
response
.
reason
)
some_notification_failed
=
True
except
socket
.
error
as
exc
:
sys
.
stderr
.
write
(
"Connection with remote server at %s failed:
\
n
"
%
notif_url
)
sys
.
stderr
.
write
(
traceback
.
format_exc
(
exc
))
some_notification_failed
=
True
if
some_notification_failed
:
...
...
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