So I am making this program and I would like to get a list value from a thread outside of the thread. With the queue module I can get a value, but not a list. Deque seems to do what I want, but only works if the deque is being read inside another thread. What I got so far:
from collections import deque
import datetime
values = deque()
def addValues(values):
while True:
found = 1
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
values.append((found,now))
time.sleep(5)
t1 = threading.Thread(target=addValues, args=(values,))
t1.start()
while True:
print(values)
time.sleep(5)
At the moment it just prints an empty deque. I want it to print the deque with the added values
EDIT: Nevermind, I asked the wrong question. The whole thread should be in a Flask site. when I at return to the while True, than it doesn't return anything. Sorry, I will make another question for this
Works for me:
deque([(1, '2018-01-30 14:38:22')])
deque([(1, '2018-01-30 14:38:22'), (1, '2018-01-30 14:38:27')])
deque([(1, '2018-01-30 14:38:22'), (1, '2018-01-30 14:38:27'), (1, '2018-01-30 14:38:32')])
Python 3.6.3