Skip to content

Commit 7f160b0

Browse files
committed
Merge pull request #1142 from nipy/enh/allow_extended_xvfb
MRG:Allow extra wait time for Xvfb if needed
2 parents b9ff1ba + 3e299d7 commit 7f160b0

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ Next release
5858
* ENH: Added -newgrid input to Warp in AFNI (3dWarp wrapper) (https://github.com/nipy/nipype/pull/1128)
5959
* FIX: Fixed AFNI Copy interface to use positional inputs as required (https://github.com/nipy/nipype/pull/1131)
6060
* ENH: Added a check in Dcm2nii to check if nipype created the config.ini file and remove if true (https://github.com/nipy/nipype/pull/1132)
61+
* ENH: Use a while loop to wait for Xvfb (up to a max wait time "xvfb_max_wait" in config file, default 10)
62+
(https://github.com/nipy/nipype/pull/1142)
6163

6264
Release 0.10.0 (October 10, 2014)
6365
============

doc/users/config_file.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ Execution
125125
all pending jobs and checking for job completion. To be nice to cluster
126126
schedulers the default is set to 60 seconds.
127127

128+
*xvfb_max_wait*
129+
Maximum time (in seconds) to wait for Xvfb to start, if the _redirect_x parameter of an Interface is True.
130+
128131
Example
129132
~~~~~~~
130133

nipype/interfaces/base.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -994,9 +994,13 @@ def run(self, **inputs):
994994
xvfb_proc = subprocess.Popen(xvfb_cmd,
995995
stdout=open(os.devnull),
996996
stderr=open(os.devnull))
997-
time.sleep(0.2) # give Xvfb time to start
998-
if xvfb_proc.poll() is not None:
999-
raise Exception('Error: Xvfb did not start')
997+
wait_step = 0.2
998+
wait_time = 0
999+
while xvfb_proc.poll() is not None:
1000+
if wait_time > config.get('execution', 'xvfb_max_wait'):
1001+
raise Exception('Error: Xvfb did not start')
1002+
time.sleep(wait_step) # give Xvfb time to start
1003+
wait_time += wait_step
10001004

10011005
runtime.environ['DISPLAY'] = ':%s' % vdisplay_num
10021006

nipype/utils/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
write_provenance = false
5252
parameterize_dirs = true
5353
poll_sleep_duration = 60
54+
xvfb_max_wait = 10
5455
5556
[check]
5657
interval = 1209600

0 commit comments

Comments
 (0)