Skip to content

Commit 1ca4960

Browse files
diningPhilosopher64Prabhakar Kumar
authored andcommitted
bugfix: os.pipe2() with flag avoids race conditions
1 parent e1f41a6 commit 1ca4960

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

jupyter_matlab_proxy/settings.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,12 @@ def create_xvfb_cmd():
154154
The second List contains a read and a write descriptor.
155155
The first List is the command to launch Xvfb process with the same write descriptor(from the first list) embedded in the command.
156156
"""
157-
dpipe = os.pipe()
157+
# Using os.pipe() can lead to race conditions (ie.usage of same set of file descriptors between 2 processes)
158+
# when called in quick succession and also when running tests.
159+
# Using os.pipe2() with the flag os.O_NONBLOCK will avoid race conditions.
160+
dpipe = os.pipe2(os.O_NONBLOCK)
161+
162+
# Allow child process to use the file descriptor created by parent.
158163
os.set_inheritable(dpipe[1], True)
159164

160165
xvfb_cmd = [

0 commit comments

Comments
 (0)