Simple example of class which goes into loop
class L:
def __init__(self):
self.data = []
self.current = 0
self.loop()
def loop(self):
while True:
self.data.append(self.current)
self.current += 1
time.sleep(2)
if __name__ == '__main__':
obj = L()
How is it possible to access obj.current?
Is it possible to create flask app, so that the loop would go in the background, so that query /get would return the obj.current?
(For example I have this object connected to Telegram. /start starts the loop, /get should receive obj.current. /start however goes into infinite loop ... )