守护程序线程不会在python中停止

时间:2016-04-15 20:35:10

标签: python multithreading

为什么主线程没有杀死守护进程?

MATCH (:Movie{title:'The Matrix'})<-[:DIRECTED]-(p:Person)
MATCH (n:Movie)<-[:WROTE]-(p)-[:DIRECTED]->(n)
RETURN p,n;

此代码的输出为:

import threading
import time

print_lock = threading.Lock()

def exampleNoneDaemon():
    for x in range(3):
        with print_lock:
            print(x, "master")
        time.sleep(0.7)

t1 = threading.Thread(target=exampleNoneDaemon)
t1.start()

def exampleDaemon():
    while True:
        with print_lock:
            print("daemon")
        time.sleep(1)

t2 = threading.Thread(target=exampleDaemon)
t2.daemon = True
t2.start()

我做错了什么?

0 个答案:

没有答案