ponty / PyVirtualDisplay

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

Dublicate display number in celery. #16

Closed StagnantIce closed 4 years ago

StagnantIce commented 8 years ago

Hello, i use PyVirtualDisplay==0.1.5 to take screenshots in celery.

        self.DISPLAY = SmartDisplay(visible=0, size=(2560, 1600), bgcolor='black').start()
        print u"Create display...%s" % self.DISPLAY.new_display_var

But sometimes new_display_var is dublicate for two workers:

[2016-02-12 04:23:20,879: WARNING/Worker-2] DISPLAY: :1098 [2016-02-12 04:44:08,713: WARNING/Worker-3] DISPLAY: :1098

Please help, thank you.

ponty commented 8 years ago

Please try the latest version!

StagnantIce commented 8 years ago

Thanks, but I already do with multiprocessing.Manager and check that display not exists. Now I have another problem. I created two tasks in celery, each create display. Display is created, but I cant see it in visible mode, and then I use browser in this display, it is obvious use old display.

I mean one worker cant work correctly with two tasks and two displays.

ponty commented 8 years ago

I don't know celery. I need a simple example. You have 2 processes, and each process has 1 display?

ponty commented 4 years ago

Concurrency is fixed in latest version.

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.