jupyter-server / enterprise_gateway

A lightweight, multi-tenant, scalable and secure gateway that enables Jupyter Notebooks to share resources across distributed clusters such as Apache Spark, Kubernetes and others.
https://jupyter-enterprise-gateway.readthedocs.io/en/latest/
Other
615 stars 220 forks source link

Resolve periodic socket.timeout causing control channel socket recycling #1381

Open MaicoTimmerman opened 2 months ago

MaicoTimmerman commented 2 months ago

For every message send from the Enterprise Gateway to the kernel, a new connection is accepted using socket.accept(). The timeout for this socket is 5 seconds: https://github.com/jupyter-server/enterprise_gateway/blob/d01e84a2457d44d14bd6bd3335307b9d0e3b483d/etc/kernel-launchers/python/scripts/launch_ipykernel.py#L293

Instead of restarting the blocking accept call, we can use select.select to check ready-state of the socket. Using this method we don't cycle the connection and delay (or miss) messages.