fix the ProtocolError exceptions

This commit is contained in:
Mylloon 2021-08-04 14:04:52 +02:00
parent 1495f24ab2
commit 1997612350

View file

@ -5,6 +5,7 @@ from re import sub
from random import choice from random import choice
from datetime import datetime from datetime import datetime
from pytz import timezone from pytz import timezone
from queue import Queue
def load(variables) -> dict: def load(variables) -> dict:
"""Load environment variables.""" """Load environment variables."""
@ -22,8 +23,9 @@ def load(variables) -> dict:
return keys return keys
class Listener(StreamListener): class Listener(StreamListener):
def __init__(self, api = None, users = None): def __init__(self, api = None, users = None, q = Queue()):
super(Listener, self).__init__() super(Listener, self).__init__()
self.q = q
self.api = api self.api = api
self.listOfFriendsID = getFriendsID(api, users) self.listOfFriendsID = getFriendsID(api, users)
@ -48,6 +50,11 @@ class Listener(StreamListener):
print(f"{status._json['user']['screen_name']} est passé au coiffeur !") print(f"{status._json['user']['screen_name']} est passé au coiffeur !")
except Exception as error: except Exception as error:
print(f"{errorMessage} {error}") print(f"{errorMessage} {error}")
def do_stuff(self):
while True:
self.q.get()
self.q.task_done()
def getFriendsID(api, users: list) -> list: def getFriendsID(api, users: list) -> list:
"""Get all friends of choosen users.""" """Get all friends of choosen users."""