The processing.Process class follows the API of threading.Thread.
上面是python doc的原话。
安装processing模块的时候遇到找不到python.h这个文件的问题。
网上搜了很多资料。都说是缺少python-dev。但是使用apt-get却一直提示缺少Python.h。我是这样解决的:
1、安装aptiude
2、使用aptitude安装python-dev
3、easy_install安装processing模块。
------------------------------------------------------
下面使用proessing来做一些例子。
fromprocessingimportProcess,Queue
importtime
deff(q):
x=q.get()
print"Process number %s,sleeps for %s seconds."% (x,x)
time.sleep(x)
print"Process number %s finished!"% x
q=Queue()
foriinrange(10):
q.put(i)
i=Process(target=f,args=[q])
i.start()
print"main process joins on queue"
i.join()
print"main finished!"
上面的代码中, 开启十个进程,每个进程休眠相应的时间然后退出。请注意其中的i.j