本文整理汇总了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'"
示例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'