Permalink
Browse files

Merge pull request #3 from ArthurClune/master

Code tidy for reconnect
  • Loading branch information...
rep committed Jun 14, 2012
2 parents 43be9c3 + 0db5dbd commit df9311aed627015f81122feca4595c835b887c77
Showing with 5 additions and 14 deletions.
  1. +5 −14 cli/csv2file.py
View
@@ -36,20 +36,11 @@ def on_error(payload):
print >>sys.stderr, ' -> errormessage from server: {0}'.format(payload)
hpc.stop()
- while True:
- try:
- hpc = hpfeeds.new(HOST, PORT, IDENT, SECRET)
- print >>sys.stderr, 'connected to', hpc.brokername
- hpc.subscribe(CHANNELS)
- except hpfeeds.FeedException:
- # failed to connect
- sleep(20)
- break
- hpc.run(on_message, on_error)
- hpc.close()
- # if we get here, connection has error'd out
- # just wait and try again
- sleep(20)
+ hpc = hpfeeds.new(HOST, PORT, IDENT, SECRET, reconnect=True)
+ print >>sys.stderr, 'connected to', hpc.brokername
+ hpc.subscribe(CHANNELS)
+ hpc.run(on_message, on_error)
+ hpc.close()
return 0
if __name__ == '__main__':

0 comments on commit df9311a

Please sign in to comment.