Hey guys, could you recommend a good way to display a progress indicator from a long running task when running a WindowCommand?
Consider this code:
def dispatch_long_running_task(msg, long_running_task):
def report(msg):
sublime.status_message(msg)
t = threading.Thread(target=long_running_task)
t.start()
report(f"{msg}")
while t.is_alive():
report(f"{msg}...")
time.sleep(0.5)
report(f"{msg}..")
time.sleep(0.5)
report(f"{msg}.")
time.sleep(0.5)
report("")
def dispatch_long_running_task2(msg, long_running_task):
def report(msg):
sublime.status_message(msg)
t = threading.Thread(target=long_running_task)
t.start()
report(f"{msg}")
t.join()
report("")
class FooCommand(sublime_plugin.WindowCommand):
def run(self, **kwargs):
def callback():
subprocess.run("ping www.google.es", shell=True)
dispatch_long_running_task("Pinging", callback)
print("Job completed...")
The idea is simple, I just want the typical 3 dots looping but for some reason the SublimeText status bar won’t be updated as intended, I’m trying to figure out why…
Thanks in advance