I'm having an issue that is really difficult to find an already made solution for it.
I'm running a new python thread that is then blocked by a socket connection (python-socketio) because it is waiting indefinitely for data. But I need to close this thread after 5 minutes.
I've tried to setup a timer that would close the thread with sys.exit() but I found that this was closing the timer thread itself.
Here is the code so far :
class LiveMatches(commands.Cog):
def __init__(self, client):
self.client = client
def connect_to_scorebot(self, id):
feed = MatchFeed(self.client)
feed.main(id) # when this function is called,
# it will block the newly created thread to receive the data with the socket
def create_thread(self, id):
# we create the thread and call launch_match that will connect to
# the scorebot
new_thread = threading.Thread(target=self.connect_to_scorebot, args=(id,))
# start the thread
new_thread.start()