ponty / PyVirtualDisplay

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

KeyError when DISPLAY not peresent in ENV #26

Closed Drachenfels closed 5 years ago

Drachenfels commented 7 years ago

This happens when I am running selenium script in a docker, not sure exactly when:

Traceback (most recent call last):
  File "/crawler/session.py", line 47, in __del__
    self.display.stop()
  File "/usr/local/lib/python3.5/dist-packages/pyvirtualdisplay/abstractdisplay.py", line 118, in stop
    self.redirect_display(False)
  File "/usr/local/lib/python3.5/dist-packages/pyvirtualdisplay/abstractdisplay.py", line 87, in redirect_display
    del os.environ['DISPLAY']
  File "/usr/lib/python3.5/os.py", line 741, in __delitem__
    raise KeyError(key) from None
KeyError: 'DISPLAY'

Not sure if this was overlooked or I do something wrong.

Bottom line is that in most places in the code similar issues with display not being part of env were navigated, this one seems like forgotten fix.

ponty commented 7 years ago

This was already fixed in #2 and #14. Do you have the latest version?