File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments