I got this snippet:
import threading
import time
count = 0
class Listener():
    def on_data(self, text, index):
        print("thread={} listener.on_data={}".format(index, text))
    def on_finished(self, index):
        print("thread={} listener.on_finished\n\n".format(index))
class AsyncProcess:
    def __init__(self, listener, index):
        self.listener = listener
        self.index = index
        self._thread = threading.Thread(target=self.run)
        self._thread.start()
    def run(self):
        for i in range(10):
            self.listener.on_data(
                'subprocess {} line {}'.format(self.index, i), self.index)
            time.sleep(0.5)
        self.listener.on_finished(self.index)
    def join(self):
        self._thread.join()
def UI_main_thread():
    global count
    for j in range(10):
        print('UI_main_thread', str(count))
        time.sleep(0.2)
        count += 1
for i in range(3):
    l = Listener()
    my_obj = AsyncProcess(l, i)
    UI_main_thread()
    my_obj.join()
print('done')
Running this one on a python console process will display in real-time the output, obviously. Now, if I try to run it on the ST main thread it will freeze the UI (ie: using UnitTesting)… I kind of understand why this is happening… problem is I don’t know how to fix it and getting a responsive equivalent script where i’ll be able to see the output in real time.
When I say equivalent I mean getting the exact same order/output of the printed data of the above attempt.
Thanks in advance.
 . Hopefully it’ll work like this so I won’t have to use semaphores or any other fancy concurrence technique to solve the problem… Btw, if you’re curious, the above snippet is an oversimplification of the original problem I’m trying to solve, which i’ve posted few days ago
 . Hopefully it’ll work like this so I won’t have to use semaphores or any other fancy concurrence technique to solve the problem… Btw, if you’re curious, the above snippet is an oversimplification of the original problem I’m trying to solve, which i’ve posted few days ago