jupyter / jupyter/notebook

Future with notebook, is this output as excepted?

Open
#5,883 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
13.3k
Forks
5.8k
Avg merge
6d 11h
Merged PRs (30d)
7

Description

![image](https://user-images.githubusercontent.com/24616044/100349651-ba266880-3023-11eb-912c-cf89f80d1ce3.png)

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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.