MCPcopy Create free account
hub / github.com/dabeaz/python-cookbook / event_loop

Function event_loop

src/11/event_driven_io_explained/eventhandler.py:24–32  ·  view source on GitHub ↗
(handlers)

Source from the content-addressed store, hash-verified

22import select
23
24def event_loop(handlers):
25 while True:
26 wants_recv = [h for h in handlers if h.wants_to_receive()]
27 wants_send = [h for h in handlers if h.wants_to_send()]
28 can_recv, can_send, _ = select.select(wants_recv, wants_send, [])
29 for h in can_recv:
30 h.handle_receive()
31 for h in can_send:
32 h.handle_send()

Callers 3

threadpool.pyFile · 0.90
tcpserver.pyFile · 0.90
udpserver.pyFile · 0.90

Calls 4

wants_to_receiveMethod · 0.45
wants_to_sendMethod · 0.45
handle_receiveMethod · 0.45
handle_sendMethod · 0.45

Tested by

no test coverage detected