Skip to content

Commit ddf7028

Browse files
authored
Workaround for launch bug (#861)
1 parent 52f908b commit ddf7028

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)