{"action":"created","issue":{"url":"https://api.github.com/repos/ponty/PyVirtualDisplay/issues/14","labels_url":"https://api.github.com/repos/ponty/PyVirtualDisplay/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/ponty/PyVirtualDisplay/issues/14/comments","events_url":"https://api.github.com/repos/ponty/PyVirtualDisplay/issues/14/events","html_url":"https://github.com/ponty/PyVirtualDisplay/issues/14","id":109138000,"number":14,"title":"When os.environ has no DISPLAY variable, PyVirtualDisplay sets it to \":0\" when calling stop() instead of deleting it","user":{"login":"adveres","id":775690,"avatar_url":"https://avatars.githubusercontent.com/u/775690?v=3","gravatar_id":"","url":"https://api.github.com/users/adveres","html_url":"https://github.com/adveres","followers_url":"https://api.github.com/users/adveres/followers","following_url":"https://api.github.com/users/adveres/following{/other_user}","gists_url":"https://api.github.com/users/adveres/gists{/gist_id}","starred_url":"https://api.github.com/users/adveres/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adveres/subscriptions","organizations_url":"https://api.github.com/users/adveres/orgs","repos_url":"https://api.github.com/users/adveres/repos","events_url":"https://api.github.com/users/adveres/events{/privacy}","received_events_url":"https://api.github.com/users/adveres/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-30T17:10:53Z","updated_at":"2015-10-22T08:24:33Z","closed_at":"2015-10-22T08:23:58Z","body":"Hi,\r\n\r\nFirst, thank you for the great library.  I believe I've found a bug.\r\nYou fixed Issue #2 by adding a default DISPLAY of \":0\" when stopping the display. This is an issue if we try to create multiple displays sequentially, because stop() is incorrectly leaving the DISPLAY environment variable set, when the key should be deleted.  I have the same use-case as Issue #2, where the CentOS machine I am running on does not have a DISPLAY environment variable by default.\r\n\r\nSee script/output below, and let me know if you need any more details. I am using xvfb on a CentOS server that has no DISPLAY by default.\r\n\r\n```python\r\nimport os\r\nimport time\r\nfrom pyvirtualdisplay import Display\r\nfrom selenium import webdriver\r\nfrom selenium.webdriver.firefox.firefox_binary import FirefoxBinary\r\n\r\n\r\ndef start():\r\n    display = None\r\n\r\n    if 'DISPLAY' not in os.environ:\r\n        print(\"  Bringing up a new display, because os.environ does not have one.\")\r\n        display = Display(visible=False, size=(1920, 1200))  # TODO is this cheating?? Huge resolution.\r\n        display.start()\r\n\r\n        print(\"  Started pyvirtualdisplay with backend '%s', screen '%s'.\" % (display.backend, display.screen))\r\n    else:\r\n        print(\"  Environ DISPLAY is '%s', no need to use pyvirtualdisplay.\" % os.environ['DISPLAY'])\r\n\r\n    # TODO do we need to sleep here for the display to start?\r\n\r\n    try:\r\n        with open(\"/tmp/firefoxLog.txt\", 'w') as log_file:\r\n            binary = FirefoxBinary(firefox_path='/usr/bin/firefox', log_file=log_file)\r\n            browser = webdriver.Firefox(firefox_binary=binary)\r\n            browser.get(\"http://www.google.com\")\r\n    except:\r\n        if display:\r\n            print(\"  Stopping display because the browser failed to come up.\")\r\n            display.stop()\r\n        else:\r\n            print(\"  No need to stop display, because we did not make one earlier.\")\r\n\r\n        raise\r\n\r\n    return display, browser\r\n\r\n\r\ndef stop(display, browser):\r\n    if browser:\r\n        print \"  Quitting browser\"\r\n        browser.quit()\r\n    if display:\r\n        print \"  Stopping display\"\r\n        display.stop()\r\n\r\n\r\nprint \"TEST1\"\r\nd1, b1 = start()\r\ntime.sleep(3)\r\nstop(d1, b1)\r\n\r\ntime.sleep(2)\r\n\r\nprint \"\\nTEST2\"\r\nd2, b2 = start()\r\ntime.sleep(3)\r\nstop(d2, b2)\r\n\r\n\r\nexit(0)\r\n\r\n```\r\n\r\nI believe this can be fixed by deleting \"DISPLAY\" from the environ dictionary if it was not there when we initially started.\r\n\r\nThank you!\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ponty/PyVirtualDisplay/issues/comments/150144215","html_url":"https://github.com/ponty/PyVirtualDisplay/issues/14#issuecomment-150144215","issue_url":"https://api.github.com/repos/ponty/PyVirtualDisplay/issues/14","id":150144215,"user":{"login":"ponty","id":584643,"avatar_url":"https://avatars.githubusercontent.com/u/584643?v=3","gravatar_id":"","url":"https://api.github.com/users/ponty","html_url":"https://github.com/ponty","followers_url":"https://api.github.com/users/ponty/followers","following_url":"https://api.github.com/users/ponty/following{/other_user}","gists_url":"https://api.github.com/users/ponty/gists{/gist_id}","starred_url":"https://api.github.com/users/ponty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ponty/subscriptions","organizations_url":"https://api.github.com/users/ponty/orgs","repos_url":"https://api.github.com/users/ponty/repos","events_url":"https://api.github.com/users/ponty/events{/privacy}","received_events_url":"https://api.github.com/users/ponty/received_events","type":"User","site_admin":false},"created_at":"2015-10-22T08:24:33Z","updated_at":"2015-10-22T08:24:33Z","body":"Thanks for the report!"}}