I'm making a stock trading app where I'm using matplotlib to create an graph that updates in real time in an event loop like so:
fig = plt.figure()
ani = animation.FuncAnimation(fig, animate, interval=2000)
plt.show()
loop.call_later(7100, renew_token)
However, I also want to run a function (renew_token) every x seconds that checks to see if the user has been logged out.
def renew_token():
response = self.session.get(url, header_auth=True)
print(response)
loop.call_later(5000, renew_token)
If I create an event loop and run the graph function, the rest of the code doesn't execute until the graph window is closed. How could I run my code in parallel with the graph updating?