生成器实现协程问题
来源:12-10 生成器实现协程

慕丝4131720
2019-07-09
代码没调通,老师q没给通过申请,老师看下我的问题啊
2回答
-
慕丝4131720
提问者
2019-07-10
def connected(key):
global client
selector.unregisted(key.fd)
client.send("GET {} HTTP/1.1\r\nHost:{}\r\nConnection:close\r\n\r\n".format(path, host).encode("utf8"))
selector.register(client.fileno(), EVENT_READ, get_socket_data)
def get_socket_data(key):
global client
data = b''
while True:
d = client.recv(1024)
if not d:
selector.unregister(key.fd)
client.close()
return data
else:
data += d
yield d。。。(省略部分与课程里源码一致)
def loop(url):
gen_download = download_html(url)
next(gen_download)
while True:
ready = selector.select()
for key, mask in ready:
call_back = key.data
call_back(key)012019-07-13 -
bobby
2019-07-10
你的代码截图我看看 没有通过是不是有异常?或者逻辑上有问题?
032019-07-10
相似问题