如何使用pyvirtualdisplay(Python)时使用TCP端口禁用Xvfb?

试图使用Python的pyvirtualdisplay来启动一些虚拟Xvfb Xterminal的应用程序。 但是,我们已经看到端口冲突,并希望禁用使用TCP端口的Xvfb 。 我已经阅读了关于做这个非常相似的问题 ,但我不明白为了使用pyvirtualdisplay (或作为默认configuration,否则)应该为此设置此configuration。

任何帮助,将非常感激。 非常感谢!

PyVirtualDisplay调用Xvfb程序,但不幸的是,它没有提供configuration发送参数到该程序的方法。 如果您想通过PyVirtualDisplay将-nolisten tcp选项传递给Xvfb,则必须编辑包中的pyvirtualdisplay / xvfb.py文件。

文件底部是定义命令和选项的这一部分:

 @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 

你需要修改它是这样的:

 @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