Closed pynasty closed 5 years ago
http://stackoverflow.com/questions/6104535/i-dont-understand-this-python-del-behaviour "you cannot assume that del will ever be called - it is not a place to hope that resources are automagically deallocated. If you want to make sure that a (non-memory) resource is released, you should make a release() or similar method and then call that explicitly (or use it in a context manager as pointed out by Thanatos in comments below)."
https://docs.python.org/2/reference/datamodel.html#object.__del__ " It is not guaranteed that del() methods are called for objects that still exist when the interpreter exits."
You should call stop() explicitly or you can use the context manager:
with Display(visible=0, bgcolor='black') as disp:
your_code()
When a display object is deleted, the display should first be stopped to avoid any issues with orphaned processes related to the virtual display.
Issue noticed on an Ubuntu server using Xvfb. Issue was not reproducible on an Ubuntu machine with a physical display. Most simple reproduction in python terminal: