import time, threading
from queue import Queue
q = Queue()
def thread_func(q, a):
w = 0
while w < 5:
time.sleep(2)
if not q.empty():
a = q.get(block=False)
print("func:" + a)
w += 1
if __name__ == "__main__":
x = threading.Thread(target=thread_func, args=(q, 'AAAA'))
x.start()
q.put(input('Введите новое значение'))
+----+-----------+------+
| id | parent_id | name |
+----+-----------+------+
+----+-----------+---------------+
| id | parent_id | department_id |
+----+-----------+---------------+