Skip to content

Commit

Permalink
Merge pull request #5353 from sohje/fix-social
Browse files Browse the repository at this point in the history
Fix mqtt connection initialization
  • Loading branch information
sohje authored Sep 10, 2016
2 parents 58257d2 + 58563b9 commit 2dc8054
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pokemongo_bot/event_handlers/social_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def publish(self, channel, message):
except UnicodeDecodeError:
pass

def connect_to_mqtt(self):
def initialize(self):
try:
if DEBUG_ON:
print 'connect again'
Expand All @@ -86,6 +86,9 @@ def run(self):
time.sleep(20)
except UnicodeDecodeError:
time.sleep(1)
except Exception as e:
print e
time.sleep(10)


class SocialHandler(EventHandler):
Expand All @@ -101,6 +104,7 @@ def handle_event(self, event, sender, level, formatted_msg, data):
print 'need connect'

self.mqttc = MyMQTTClass(self.bot, self.bot.config.client_id)
self.mqttc.initialize()
self.bot.mqttc = self.mqttc
thread.start_new_thread(self.mqttc.run)
except socket_error as serr:
Expand Down

0 comments on commit 2dc8054

Please sign in to comment.