我的节目在哪里:
php代码:
while(true) {
$records = get_records();
file_put_contents($file_name, json_encode($records));
echo "php:system:before";
system("python script.py $file_name");
echo "php:system:before";
}
python代码:
import json
import os
import sys
import time
import random
import urllib2
from multiprocessing import Pool, freeze_support
from subprocess import Popen, PIPE
from os.path import isdir
from platform import system
from lib import Logger
def do_something(record):
# ... some operations
print("python:record:done")
if __name__ == '__main__':
records = read_records
pool = Pool(4)
pool.map(do_something, records)
pool.close()
pool.join()
print("python:done")
但是不时有进程挂起。
我的日志:
php:system:start
python:record:done
python:record:done
python:record:done
python:record:done
python:record:done
python:record:done
python:record:done
python:done
<- here I expect php:system:before
但每天两次我没有得到它并且我重置了程序。 哪里出错,为什么脚本会挂起?