Comments (6)
@Sebadst you can do:
from pyvirtualdisplay import Display
display = Display()
display.start()
display.stop()
del display
display = Display()
display.start()
When calling display.stop()
it in fact stops the Xvfb, Xephir or Xvnc displays but the Display
object still exists. If I get rid of it and instantiate it again I am able to start the display again.
from pyvirtualdisplay.
You don't even have to delete the old object
>>> from pyvirtualdisplay import Display
>>> display = Display()
>>> display.start()
<pyvirtualdisplay.display.Display object at 0x7f0b585e9df0>
>>> display.stop()
<pyvirtualdisplay.display.Display object at 0x7f0b585e9df0>
>>> display = Display()
>>> display.start()
<pyvirtualdisplay.display.Display object at 0x7f0b5868b1f0>
You don't have such problems with context manager (check the README)
from pyvirtualdisplay import Display
with Display() as disp:
# display is active
pass
# display is stopped
from pyvirtualdisplay.
Display
wraps one call to Xvfb, so you can use start()
only once on it. Don't call it twice.
from pyvirtualdisplay import Display
display = Display()
display.start()
display.stop()
from pyvirtualdisplay.
what does the stop()
call do exactly then?
from pyvirtualdisplay.
start()
starts Xvfb stop()
stops Xvfb.
Example from README:
from pyvirtualdisplay import Display
disp = Display().start()
# display is active
disp.stop()
# display is stopped
from pyvirtualdisplay.
Yes, working with context manager is an alternative but in my case I had a multi-threaded scenario with the virtual display as a shared resource where using context wouldn't allow me to implement the flexibility I needed and so I ended up just deleting the old object after stopping the display to be able to start it again when required.
from pyvirtualdisplay.
Related Issues (20)
- FileNotFoundError: [Errno 2] No such file or directory: 'Xvfb' HOT 3
- Windows support for PyVirtualDisplay HOT 2
- display.start() stacks on multiple session HOT 1
- GPU/Hardware Acceleration HOT 4
- module not found HOT 2
- Chrome Options Not Working Properly Or User Error? HOT 1
- "Not a valid VNC server" when running VNC example HOT 2
- Set new session on created display
- XIO: fatal IO error 22 (Invalid argument) on X server ":0" after 143 requests (136 known processed) with 12 events remaining. HOT 1
- FileNotFoundError: [WinError 2] Impossibile trovare il file specificato (impossible to find the specified file) HOT 1
- Never clear values from _USED_DISPLAY_NR_LIST HOT 3
- Issues with wsl2 + win11 HOT 4
- Do there have way to make work it with windows? HOT 1
- mouse control or keyboard HOT 3
- Using backend 'xvnc' emits error 'Unrecognized option: -SecurityTypes' HOT 3
- FileNotFoundError: [Errno 2] No such file or directory: 'Xvnc': 'Xvnc' for Mac OS HOT 4
- add -glamor flag for xephyr backend for gpu acceleration HOT 1
- ValueError: filedescriptor out of range in select()
- Selenium and Chrome DevToolsActivePort file doesn't exist after 89/90 chrome invocations HOT 4
- FileNotFoundError: [WinError 2] The system cannot find the file specified
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyvirtualdisplay.