ponty / PyVirtualDisplay

Python wrapper for Xvfb, Xephyr and Xvnc
BSD 2-Clause "Simplified" License
709 stars 78 forks source link

Have a better way to get unique display number #30

Closed ionelmc closed 4 years ago

ionelmc commented 6 years ago

Currently there's the RANDOMIZE_DISPLAY_NR users can patch to get better concurrent behavior but it's contrived to use.

Could we have a better API for this? Or maybe an atomic "get number and lock file"?

ponty commented 4 years ago

Concurrency is solved.

From latest README:

Concurrency

"Recent X servers as of version 1.13 (Xvfb, too) support the -displayfd command line option: It will make the X server choose the display itself" https://stackoverflow.com/questions/2520704/find-a-free-x11-display-number/

First help text is checked (e.g. Xvfb -help) to find if -displayfd flag is available. If -displayfd flag is available then it is used, if not then there are 10 retries by default which should be enough for starting 10 concurrent X servers. The retries parameter can be increased if necessary.