Skip to content

Commit

Permalink
added debug log points in client
Browse files Browse the repository at this point in the history
  • Loading branch information
guyzmo committed May 31, 2012
1 parent 2d621de commit 9f1a4e8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions eventsource/client.py
Expand Up @@ -40,6 +40,8 @@ def __init__(self,url,action,target,callback=None,retry=0):
:param callback: function with one parameter (Event) that gets called for each received event
:param retry: timeout between two reconnections (0 means no reconnection)
"""
log.debug("EventSourceClient(%s,%s,%s,%s,%s)" % (url,action,target,callback,retry))

self._url = "http://%s/%s/%s" % (url,action,target)
AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")
self.http_client = AsyncHTTPClient()
Expand All @@ -58,6 +60,8 @@ def poll(self):
"""
Function to call to start listening
"""
log.debug("poll()")

if self.retry_timeout == 0:
self.http_client.fetch(self.http_request, self.handle_request)
IOLoop.instance().start()
Expand All @@ -70,6 +74,8 @@ def end(self):
"""
Function to call to end listening
"""
log.debug("end()")

self.retry_timeout=0
IOLoop.instance().stop()

Expand All @@ -80,6 +86,8 @@ def handle_stream(self,message):
parse all the fields and builds an Event object that is passed to the callback function
"""
log.debug("handle_stream(...)")

event = Event()
for line in message.strip('\r\n').split('\r\n'):
(field, value) = line.split(":",1)
Expand Down Expand Up @@ -114,6 +122,8 @@ def handle_request(self,response):
:param response: tornado's response object that handles connection response data
"""
log.debug("handle_request(response=%s)" % (response,))

if response.error:
log.error(response.error)
else:
Expand Down

0 comments on commit 9f1a4e8

Please sign in to comment.