Bug 252602

Summary: www/py-notebook: Python kernel does not work since tornado websockets use Future
Product: Ports & Packages Reporter: Thibault Payet <monwarez>
Component: Individual Port(s)Assignee: Po-Chuan Hsieh <sunpoet>
Status: Closed FIXED    
Severity: Affects Only Me CC: rm
Priority: --- Flags: bugzilla: maintainer-feedback? (python)
Version: Latest   
Hardware: Any   
OS: Any   

Description Thibault Payet 2021-01-12 10:29:52 UTC
Since tornado websockets use python Future, the python3 kernel crash at file

/usr/local/lib/python3.7/site-packages/notebook/services/kernels/handlers.py

at the line 207

https://github.com/jupyter/notebook/blob/57db70979b677b0c47cbecfbfbc3ba5b359bc0b3/notebook/services/kernels/handlers.py#L207


if self.ws_connection is None or self.ws_connection.is_closing():

Here since self.ws_connection is a Future it does not have the member: is_closing

A fix would be to wait for the Future result (with or without a timeout) :

websocket = self.ws_connection.result()

And then check for
websocket.is_closing()

The dirty fix would be to ignore the test on is_closing

With the dirty fix the kernel run

The github repos have over 2k issue, it is hard to find if this error was already reported there.
Comment 1 Ruslan Makhmatkhanov freebsd_committer freebsd_triage 2021-01-25 09:33:52 UTC
Yes, www/py-tornado should be updated to 6.x according to https://github.com/jupyter/notebook/issues/5920

@sunpoet, could you make the update, please? jupyter-notebook is now completely broken in ports.
Comment 2 Po-Chuan Hsieh freebsd_committer freebsd_triage 2021-01-26 19:40:48 UTC
(In reply to Ruslan Makhmatkhanov from comment #1)

Upstream did not change tornado requirement in 6.1.6 [1].

I've updated py-tornado to 6.1 in r562985. It should fix the problem.

[1] https://github.com/jupyter/notebook/blob/6.1.6/setup.py#L101
Comment 3 Ruslan Makhmatkhanov freebsd_committer freebsd_triage 2021-01-26 20:15:05 UTC
(In reply to Sunpoet Po-Chuan Hsieh from comment #2)

They actually did afterwards:
https://github.com/jupyter/notebook/blob/master/setup.py#L101

Thank you for updating www/py-tornado! My plan was to just switch the port to tornado6, but it required to make the same change to other ports like ipykernel, terminado, jupyter_client etc. I did that locally with testing purpose and it fixed notebook runtime. But your solution is better, not sure if it breaks anything for other consumers.
Comment 4 Po-Chuan Hsieh freebsd_committer freebsd_triage 2021-02-01 20:27:45 UTC
(In reply to Ruslan Makhmatkhanov from comment #3)

I've built all dependent ports of py-tornado. Hopefully nothing is broken yet.
Thanks.