سؤال

I have a php script that runs many python scripts. The python scripts utilize a headless firefox browser using pyvirtualdisplay and xvfb. My issue is that each python script opens a new Xvfb process on my linux server. Thus I get multiple processes stacking up and eventual run out of /tmp/ space.
My issue is similar to this one:
Xvfb multiple displays for parallel processing?
I would like to have one Xvfb server process open at all times and have all the python scripts utilize it.
Here is the python code I am using:
#set pyvirtual display
display = Display(visible=0, size=(800, 600))
display.start()

هل كانت مفيدة؟

المحلول

I have resolved this issue by removing these lines from my python code:
#set pyvirtual display
display = Display(visible=0, size=(800, 600))
display.start()

and adding the following lines:
import os
os.environ['DISPLAY'] = ':1'

This way the python script uses the already open Xvfb process setup on display 1 instead of starting a new Xvfb server process.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top