I am trying to open jupyter notebook in a thread in order to capture the token of the output command, my script is opening jupyter, but seems that script get blocked because jupyter is running. So I can not get the command output.
import time
import concurrent.futures
import subprocess
start = time.perf_counter()
def open_jupyter():
jupyter_cmd = 'jupyter notebook --ip 0.0.0.0 --port 8888 --allow-root'
jupyter_open = subprocess.check_output(jupyter_cmd, shell=True)
jupyter_output = jupyter_open.decode("utf-8")
return jupyter_output
with concurrent.futures.ThreadPoolExecutor() as executor:
f = executor.submit(open_jupyter)
print (f.result())
finish = time.perf_counter()
print (f"Finished in {round(finish-start,2)} second(s)")
Any idea what is happening?