Skip to content
This repository was archived by the owner on Jul 7, 2023. It is now read-only.

Commit 1f4d661

Browse files
author
Błażej O
committed
Improved handling of Xvfb server.
1 parent 3cf9c38 commit 1f4d661

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tensor2tensor/rl/envs/utils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,12 @@ def __init__(self, constructor, xvfb):
112112

113113
xauthority_path = '/tmp/Xauthority_{}'.format(auth_file_id)
114114

115-
command = 'xvfb-run -s "-screen 0 1400x900x24" -n {} -f {} sleep 1000d'.format(server_id, xauthority_path)
116-
117-
proc = subprocess.Popen(command, shell=True)
118-
atexit.register(lambda: os.killpg(os.getpgid(proc.pid), signal.SIGTERM))
115+
command = 'Xvfb :{} -screen 0 1400x900x24 -nolisten tcp -auth {}'.format(
116+
server_id, xauthority_path)
117+
with open(os.devnull, 'w') as devnull:
118+
proc = subprocess.Popen(command.split(), shell=False, stdout=devnull,
119+
stderr=devnull)
120+
atexit.register(lambda: os.kill(proc.pid, signal.SIGKILL))
119121

120122
def constructor_using_xvfb():
121123
os.environ["DISPLAY"] = ":{}".format(server_id)

0 commit comments

Comments
 (0)