我已经在我的进程中添加了一个 apscheduler 作业,我发现我的子进程也有这个作业,并且我的主进程和子进程同时执行该作业......
主程序是
server = StreamServer((server_ip, server_port), serve_forever, spawn = pool, backlog=100000)
for i in range(process_count - 1):
Process(target=serve_forever, args=()).start()
我的调度程序是
scheduler =BackgroundScheduler()
scheduler.add_job(tick, 'interval', seconds=3)
scheduler.start()
输出是
Tick! The time is: 1409042763.26 pocess is 11428
Tick! The time is: 1409042763.26 pocess is 11431
Tick! The time is: 1409042763.26 pocess is 11424
Tick! The time is: 1409042763.26 pocess is 11430
Tick! The time is: 1409042763.26 pocess is 11426
Tick! The time is: 1409042763.26 pocess is 11380
Tick! The time is: 1409042763.26 pocess is 11425
Tick! The time is: 1409042763.26 pocess is 11429
Tick! The time is: 1409042763.26 pocess is 11432
Tick! The time is: 1409042763.26 pocess is 11433