Open xiexiaoy opened 7 years ago
奇怪,Tornado没有暴露_handler_connection()方法
Python线程调度的时机
我还纳闷Tornado为什么没有提供on_connection()方法, 原来,它提供了closed()方法。
从使用的角度看, coroutine跟threading的用法必须相似。 所以,需要有coroutine的创建销毁、coroutine的同步、coroutine间的通信。
bytes对象,不可变对象 bytearray对象,可变对象
Python 函数内部的静态变量
What is the Python equivalent of static variables inside a function?
找个sorteddict SortedContainers
socket.recv()返回什么,以及如何检查对方关闭连接?
当对方关闭连接的时候,socket.recv()返回空字符串而不是返回None。因此
data = sock.recv(bufsize)
if data:
...
else:
handle_close()
而不是
data = sock.recv(bufsize)
if data is not None:
...
else:
handle_close()
注意if something is not None
与if something
不等价。
When does socket.recv(recv_size) return? Most elegant way to check if the string is empty in Python?
ConnectionResetError: [Errno 104] Connection reset by peer
try:
...
except OSError:
...
捕获OSError竟然漏掉了ConnectionResetError
python -m http.server
what-is-the-python-3-equivalent-of-python-m-simplehttpserver
善用列表展开式 print(*list)
如何找到模块路径