知识卡片
事件处理器声明兴趣并响应
EventHandler用fileno暴露可等待资源,wants_to_receive/send声明当前兴趣,handle_receive/send完成相应处理。
结构图:
classDiagram
class EventHandler {
+fileno()
+wants_to_receive()
+handle_receive()
+wants_to_send()
+handle_send()
}
EventHandler <|-- UDPServer
UDPServer <|-- UDPTimeServer
UDPServer <|-- UDPEchoServer
EventHandler <|-- TCPServer
EventHandler <|-- TCPClient
TCPClient <|-- TCPEchoClient
图为原协议继承;同名TCPServer/UDPServer是本节自定义类型,不是socketserver类。兴趣随状态变化而变,循环调用协议不自动处理异常、关闭或所有平台的select容量限制。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- · 查看原书依据
class EventHandler: def fileno(self): 'Return the associated file descriptor' raise NotImplemented('must implement') def wants_to_recei
参考来源
- 位置:《Python Cookbook(第3版)中文版》11.12 理解事件驱动型I/O(spine19;extracted/Python Cookbook(第3版)中文版/_epub-src/OEBPS/Text/part0017.xhtml;u207-ch11-035)。
- 结论依据:完整读取本条问题、方案、代码与讨论;结论按真实控制流和适用前提表达,额外边界明确为解释或推导,示例未执行。
- 原始内容:class EventHandler: def fileno(self): 'Return the associated file descriptor' raise NotImplemented('must implement') def wants_to_recei