Commit ac4c75c6 authored by Marco Mariani's avatar Marco Mariani Committed by Cédric de Saint Martin

pubsub notifier: handle timeout and other connection errors

Signed-off-by: default avatarCédric de Saint Martin <cedric.dsm@tiolive.com>
parent 8b067d63
......@@ -9,6 +9,7 @@ import socket
import subprocess
import sys
import time
import traceback
import urllib2
import urlparse
import uuid
......@@ -80,15 +81,19 @@ def main():
notification_port = socket.getservbyname(notification_url.scheme)
headers = {'Content-Type': feed.info().getheader('Content-Type')}
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:
sys.exit(1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment