Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mqtt connection initialization #5353

Merged
merged 2 commits into from
Sep 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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