def _ensure_event_thread():
"""
Make sure the event thread is running, which checks the handlerqueue
for new event handlers to create, and runs the message pump.
"""
global _event_thread
if not _event_thread:
def loop():
while _event_thread:
pythoncom.PumpWaitingMessages()
if _handlerqueue:
(context, listener, callback) = _handlerqueue.pop()
# Just creating a _ListenerCallback object makes events
# fire till listener loses reference to its grammar object
_ListenerCallback(context, listener, callback)
time.sleep(.5)
_event_thread = 1 # so loop doesn't terminate immediately
_event_thread = _thread.start_new_thread(loop, ())
评论列表
文章目录