Reputation: 31481
Consider the following code:
#!/usr/bin/env python
from Xlib.display import Display
import os
def main():
disp = Display() # connect to display
while True:
print("1")
event = disp.next_event()
print("2")
if event.type == Xlib.protocol.event.KeyPress:
print("keypress!")
if __name__ == '__main__':
main()
This code outputs 1
but does not output 2
. It seems to be hanging on the display connection. Why might that be? Thank you.
Upvotes: 0
Views: 59
Reputation: 19862
The method next_event() is a blocking method, see the documentation:
Return the next event in the event queue. If the event queue is empty, block until an event is read from the network, and return that one.
If it is blocked it is because no event has yet arrived.
Upvotes: 1