cgoldberg / xvfbwrapper

Manage headless displays with Xvfb (X virtual framebuffer)
Other
295 stars 52 forks source link

`_get_next_unused_display` broken on Ubuntu 16.04 + Python 3.5 #15

Closed amagee closed 8 years ago

amagee commented 8 years ago

Something seems to have changed when I upgraded from Ubuntu 15.10 with Python 3.4 to Ubuntu 16.04 with Python 3.5. Everything used to work fine, but now the _get_next_unused_display method fails to find the lock files in the right place and as a result xvfbwrapper will try to open multiple Xvfb instances on the same port when run in parallel.

The problem seems to be that tempfile.gettempdir cannot be relied on to return the same directory that Xvfb actually uses. In my case, the actual log files exist in /tmp, but tempfile.gettempdir() returns /tmp/amagee. I am able to fix the problem by changing

    tmpdir = tempfile.gettempdir()

to

    tmpdir = "/tmp"

but obviously this is not a portable solution and I'm not sure what would be.

The docs for tempfile.gettempdir (https://docs.python.org/3/library/tempfile.html#tempfile.gettempdir) say:

Python searches a standard list of directories to find one which the calling user can create files in. The list is:

  1. The directory named by the TMPDIR environment variable.

And my TMPDIR environment variable is indeed /tmp/amagee.

amagee commented 8 years ago

Bah, never mind, you've already fixed this.

JulienPalard commented 8 years ago

This is still broken for me: I have a xvfbwrapper with another TMPDIR than the Xvfb tmpdir, so each Xvfb instance are string with display number 1 and only the first succeed.