3

Trying to use pyvirtualdisplay for Python to start some applications with a virtual Xvfb X terminal. However, we've seen port clashes and would like to disable Xvfb from using TCP ports. I have read this question about doing something very similar to this, but I do not understand where this configuration should be set for it in order to work with pyvirtualdisplay (or as the default configuration otherwise).

Any help with this will be very appreciated. Thanks very much!

Juan Carlos Coto
  • 677
  • 2
  • 6
  • 13

1 Answers1

2

PyVirtualDisplay invokes the Xvfb program, but unfortunately it does not provide a way to configure sending parameters to that program. If you want to pass the -nolisten tcp option to Xvfb with PyVirtualDisplay, you will have to edit the pyvirtualdisplay/xvfb.py file in the package.

At the bottom of the file is this section which defines the command and options:

@property
def _cmd(self):
    cmd = [PROGRAM,
           dict(black='-br', white='-wr')[self.bgcolor],
           '-screen',
           str(self.screen),
           'x'.join(map(str, list(self.size) + [self.color_depth])),
           self.new_display_var,
           ]
    return cmd

You'll need to modify it to be something like this:

@property
def _cmd(self):
    cmd = [PROGRAM,
           dict(black='-br', white='-wr')[self.bgcolor],
           '-screen',
           str(self.screen),
           'x'.join(map(str, list(self.size) + [self.color_depth])),
           self.new_display_var,
           '-nolisten',
           'tcp',
           ]
    return cmd
ioscode
  • 136
  • 4