Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dealing with race conditions #41

Open
leej3 opened this issue Sep 4, 2020 · 0 comments
Open

dealing with race conditions #41

leej3 opened this issue Sep 4, 2020 · 0 comments

Comments

@leej3
Copy link

leej3 commented Sep 4, 2020

I am having an issue with parallel execution when using Xvfb.

For the purposes of testing, I am attempting to run programs on several virtual displays at once, as well as some on the physical display. I need to run some things on the physical display for the tests to work on MacOS (Xvfb on Xquartz is not compiled with support for the GLX extension by default and some of the programs I am trying to run make use of OpenGL).

Currently the only way I see to run all of this is to use a resource lock for physical and virtual displays alike. This is because os.environ['DISPLAY'] is overwritten when the Xvfb instance is started and restored to its original value when it is stopped. I would like to avoid this as it would greatly slow down the testing.

Based on my understanding of the xvfbwrapper code, the problem would be fixed by an optional argument environ which is modified in place of os.environ (which would be the default value for the variable).

So usage would be something like:

locally_scoped_environ = os.environ.copy()
xvfb = Xvfb(environ=locall_scoped_environ)
xvfb.start()
subprocess.run("cmd",env=locally_scoped_environ)
xvfb.stop()

This would prevent other threads being exposed to the change in the DISPLAY variable but still make use of the resource locking that currently occurs for virtual displays. Would a PR for this functionality be welcome/accepted?

Another detail that may or may not be relevant is that I am running this using pytest and the pytest-parallel plugin with the --worker flag for several processes at once... or at least the documentation indicates that each worker is run in a separate process but my understanding is that os.environ changes would not effect the environment of other workers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant