当前位置: 首页>>代码示例>>Python>>正文


Python Process.recv方法代码示例

本文整理汇总了Python中multiprocessing.Process.recv方法的典型用法代码示例。如果您正苦于以下问题:Python Process.recv方法的具体用法?Python Process.recv怎么用?Python Process.recv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在multiprocessing.Process的用法示例。


在下文中一共展示了Process.recv方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: str

# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import recv [as 别名]
    # Send GET to peer
    try:
        p.send("GET RFC " + str(prfc.rfc_num) + " " + VERSION + "\r\n" \
            + "Host: " + str(prfc.hostname) + "\r\n" + "OS: " + str(OS) \
            + "\r\n\r\n")
    except IOError, e:
        if e.errno == errno.EPIPE:
            print "PEER ERROR: There is no peer on", prfc.hostname + ":" \
                + str(prfc.port)
            p.close()
            return
        else:
            print "PEER ERROR: There was an IOError", e.errno

    # Receive response
    response = str(p.recv(4096))
    if DEBUG:
        print "PEER FROM PEER: \n" + response,

    p.close()

    # Validate response
    rarray = response.split()
    if rarray[0] == VERSION and rarray[1] == "200" and rarray[2] == "OK" \
        and rarray[3] == "Date:" and rarray[10] == "OS:" \
        and rarray[12] == "Last-Modified:" and rarray[19] == "Content-Length:" \
        and rarray[21] == "Content-Type:" and rarray[22] == "text/plain":
        pass
    elif rarray[0] == VERSION and rarray[1] == "400" and rarray[2] == "Bad" \
        and rarray[3] == "Request":
        print "Peer responded with a '400 Bad Request'"
开发者ID:dfarrell07,项目名称:P2P-for-RFCs,代码行数:33,代码来源:client.py

示例2: Process

# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import recv [as 别名]
         raise


if __name__ == "__main__":
    #t = threading.Thread(target=print_time)
    #t.daemon = True
    #t.start()

    #time.sleep(1)
    #stop_thread(t)
    #print("stoped")
    #time.sleep(100)
    #while 1:
    #    time.sleep(1)


    p = Process(target = print_time)
    p.daemon = True
    p.start()
    #p.terminate()
    while True:
        if p.exception:
            print p.exception
        else:
            print p.recv()

        time.sleep(1)

    print 'end'

开发者ID:zhangxj,项目名称:esbi,代码行数:31,代码来源:stop_thread.py


注:本文中的multiprocessing.Process.recv方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。