#!/usr/bin/env python
# encoding: utf-8
import time
from multiprocessing import Process, Value
def func1(dict_):
while True:
dict_["has_heartbeat"].value = True
print id(dict_["has_heartbeat"]), "22222222222222"
time.sleep(0.5)
if __name__ == '__main__':
d = {"has_heartbeat": Value('i', 1)}
p1 = Process(target=func1, args=(d,))
p1.daemon = True
p1.name = "p1"
p1.start()
d["has_heartbeat"].value = False
print id(d["has_heartbeat"]), "11111111111111"
time.sleep(3)
if not d["has_heartbeat"].value:
print "has not heartbeat"
else:
print "has heartbeat"
while True:
time.sleep(3)
multiprocess Value
最新推荐文章于 2024-07-20 17:12:48 发布