You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pydevd_comm.py start_client() does not set TCP_NODELAY on the connections it opens #2054
Python version (& distribution if applicable, e.g. Anaconda): 3.11 and later
Using VS Code or Visual Studio: No
Actual behavior
TCP_NODELAY is not set on the connections debugpy opens
Expected behavior
TCP_NODELAY is set on the connections debugpy opens
Steps to reproduce:
A connection established with debugpy --connect does not set TCP_NODELAY on the socket connection, which can cause latency when sending responses and events. This is can be verified simply by inspecting the pydevd_comm.py source code, or by using external tools to inspect the connection once it has been established.
We patched our copy of debugpy 1.8.20 as follows:
%diff--gita/3rdparty/debugpy/DEBUGPY/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.pyb/3rdparty/debugpy/DEBUGPY/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.pyindex64ac454f29..812bf59eb0100644---a/3rdparty/debugpy/DEBUGPY/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py+++b/3rdparty/debugpy/DEBUGPY/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py
@@ -524,6+524,15 @@ defstart_client(host, port):
except (AttributeError, OSError):
pass# May not be available everywhere.+try:
+# TVT-46072: "Missing TCP_NODELAY on debugpy's DAP tracer connection+# causes Nagle-induced latency in Python debugging". Disable Nagle's+# algorithm so small DAP messages are sent immediately instead of+# being buffered, reducing round-trip latency.+s.setsockopt(socket_module.IPPROTO_TCP, socket_module.TCP_NODELAY, 1)
+except (AttributeError, OSError):
+pass# May not be available everywhere.+try:
# 10 seconds default timeouttimeout=int(os.environ.get("PYDEVD_CONNECT_TIMEOUT", 10))
%
Activity
nightcityblade commentedon Aug 16, 2026
Hi, I'd like to work on this. I'll submit a PR shortly.