Carnets icon indicating copy to clipboard operation
Carnets copied to clipboard

time.sleep() inside thread

Open 7points opened this issue 3 years ago • 1 comments

The following script runs in all tested jupyter apps/progs, even juno, but carnets (plus) doesn't. The expression time.sleep(0.2) stops execution.

import threading
from IPython.display import display
import ipywidgets as widgets
import time
progress = widgets.FloatProgress(value=0.0, min=0.0, max=1.0)

def work(progress):
    total = 100
    for i in range(total):
        time.sleep(0.2)
        progress.value = float(i+1)/total

thread = threading.Thread(target=work, args=(progress,))
display(progress)
thread.start()

7points avatar Apr 10 '21 10:04 7points

Thanks for raising this issue. I'll have a look, but given that the server and client are both running in threads, adding threads in the notebook and then sleeping is always difficult. You might be causing the notebook thread to sleep, instead of the thread created by the notebook.

holzschu avatar May 09 '21 12:05 holzschu