1- # $Id: display.py,v 1.23 2006-07-19 21:51:03 mggrant Exp $
1+ # $Id: display.py,v 1.24 2006-07-19 23:05:52 mggrant Exp $
22# -*- coding: latin-1 -*-
33#
44# Xlib.protocol.display -- core display communication
@@ -163,7 +163,7 @@ def next_event(self):
163163 # whether there are one active.
164164 self .send_recv_lock .acquire ()
165165
166- # Relase event queue to allow an send_and_recv to
166+ # Release event queue to allow an send_and_recv to
167167 # insert any now.
168168 self .event_queue_write_lock .release ()
169169
@@ -363,16 +363,21 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None)
363363
364364 # We go to sleep if there is already a thread doing what we
365365 # want to do:
366-
367- # If flushing or waiting for a request we want to send
368- # If waiting for an event we want to recv
366+
367+ # If flushing, we want to send
368+ # If waiting for a response to a request, we want to send
369+ # (to ensure that the request was sent - we alway recv
370+ # when we get to the main loop, but sending is the important
371+ # thing here)
372+ # If waiting for an event, we want to recv
373+ # If just trying to receive anything we can, we want to recv
369374
370375 if (((flush or request is not None ) and self .send_active )
371376 or ((event or recv ) and self .recv_active )):
372377
373378 # Signal that we are waiting for something. These locks
374379 # together with the *_waiting variables are used as
375- # semaphores. When an event or a reqeust respone arrives,
380+ # semaphores. When an event or a request response arrives,
376381 # it will zero the *_waiting and unlock the lock. The
377382 # locks will also be unlocked when an active send_and_recv
378383 # finishes to signal the other waiting threads that one of
@@ -381,7 +386,6 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None)
381386 # All this makes these locks and variables a part of the
382387 # send_and_recv control logic, and hence must be modified
383388 # only when we have the send_recv_lock locked.
384-
385389 if event :
386390 wait_lock = self .event_wait_lock
387391 if not self .event_waiting :
@@ -489,13 +493,13 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None)
489493 writeset = []
490494
491495 # Timeout immediately if we're only checking for
492- # something to read, otherwise block
496+ # something to read or if we're flushing , otherwise block
493497
494- if recv :
498+ if recv or flush :
495499 timeout = 0
496500 else :
497501 timeout = None
498-
502+
499503 rs , ws , es = select .select ([self .socket ], writeset , [], timeout )
500504
501505 # Ignore errors caused by a signal recieved while blocking.
0 commit comments