Skip to content

Commit 4029f6c

Browse files
Backport PR #861 on branch 7.x (Workaround for launch bug) (#862)
Co-authored-by: Steven Silvester <[email protected]>
1 parent 8978d52 commit 4029f6c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

jupyter_client/connect.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,18 @@ def write_connection_file(
158158
cfg["signature_scheme"] = signature_scheme
159159
cfg["kernel_name"] = kernel_name
160160

161+
# Prevent over-writing a file that has already been written with the same
162+
# info. This is to prevent a race condition where the process has
163+
# already been launched but has not yet read the connection file.
164+
if os.path.exists(fname):
165+
with open(fname) as f:
166+
try:
167+
data = json.load(f)
168+
if data == cfg:
169+
return fname, cfg
170+
except Exception:
171+
pass
172+
161173
# Only ever write this file as user read/writeable
162174
# This would otherwise introduce a vulnerability as a file has secrets
163175
# which would let others execute arbitrarily code as you

0 commit comments

Comments
 (0)