Future with notebook, is this output as excepted?
- Dominant language
- Jupyter Notebook
- Stars
- 13.3k
- Forks
- 5.8k
- Avg merge
- 6d 11h
- Merged PRs (30d)
- 7
Description

in the first code_cell, i use future in the first code_cell.
when i have run the first code_cell, i run the second code_cell imidietely.
so as the picture show, "after tid " is outputed in the second code_cell.
i have known how this happen. my question is, is this as excepted? is there some similiar problem?
##code is below
import time
from tornado.ioloop import IOLoop, PeriodicCallback
from tornado.gen import coroutine
from concurrent.futures import Future
import threading
g = None
@coroutine
def func():
t = threading.currentThread()
future = Future()
print("before tid={}".format(t))
def callback():
#time.sleep(1)
future.set_result(5)
#tornado.ioloop.IOLoop.instance().add_callback(callback)
g = PeriodicCallback(callback, 16000)
g.start()
result = yield future
t = threading.currentThread()
print("after tid={}".format(t))
print(time.time())
g.stop();
func()
Contributor guide
Research direction
Start by reproducing the two code cells using the provided Python, Tornado, and Future example, and compare the thread and output timing shown in the report. Determine whether the observed output is expected notebook behavior; completion would require a confirmed behavior description or a clearly scoped fix, neither of which is specified here.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter-notebook, python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100