0
我有python脚本,它必须执行给定次数的操作。我使用supervisord来运行这个脚本的多个实例。每个脚本都有类似的代码如下:在由supervisord运行的子进程之间共享数据
count = 0
while count != MAX_COUNT:
try:
perform_action()
count += 1
except Exception, e:
print 'Error happened...'
print e
因此,例如,我运行10个进程和MAX_COUNT = 1000。在这种情况下,每个脚本将执行1000次1000次。但我需要1000次。所以,我需要在所有supervisord子流程之间分享执行perform_action()的count
。
我该怎么办?
我想使用redis \ memcached \ sqlite - 但也许这里是另一种解决方案?
所以,你认为 - 使用简单的文件(例如)将是个好主意? – dizpers
我更喜欢共享内存。或者可能使用线程比多进程更容易修改此场景的共享变量。 – hago
http://docs.python.org/2/library/ipc.html – soulseekah