socket_afile.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:pycos 作者: pgiri 项目源码 文件源码
def server_proc(conn, task=None):
    # conn is a synchronous socket (as it is obtained from synchronous
    # 'accept'); it's file-descriptor is converted to asynchronous
    # file to read data from that
    afd = pycos.asyncfile.AsyncFile(conn)
    csum = hashlib.sha1()
    nlines = 0
    while True:
        # read lines from data
        line = yield afd.readline()
        if not line:
            break
        csum.update(line)
        nlines += 1
    afd.close()
    print('server sha1 csum: %s' % (csum.hexdigest()))
    print('lines: %s' % (nlines))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号