我正在尝试在 QuTiP 中运行一些代码,但是当我并行运行一个函数parfor
时出现错误。
results= parfor(func2, range(len(delta)))
错误:
AssertionError
Traceback (most recent call last)
<ipython-input-206-6c2ffcb32b4f> in <module>()
----> 1 results= parfor(func2, range(len(delta)))
/usr/lib/python2.7/dist-packages/qutip/parallel.pyc in parfor(func, *args, **kwargs)
119 try:
120 map_args = ((func, v, os.getpid()) for v in var)
--> 121 par_return = list(pool.map(task_func, map_args))
122
123 pool.terminate()
/usr/lib/python2.7/multiprocessing/pool.py in map(self, func, iterable, chunksize)
249 '''
250 assert self._state == RUN
--> 251 return self.map_async(func, iterable, chunksize).get()
252
253 def imap(self, func, iterable, chunksize=1):
/usr/lib/python2.7/multiprocessing/pool.py in get(self, timeout)
556 return self._value
557 else:
--> 558 raise self._value
559
560 def _set(self, i, obj):
AssertionError: daemonic processes are not allowed to have children
这是我的代码:
def func2(x):
def H1_coeff(t,args):
return exp(-((t-4)/2.0) ** 2)
H0 = np.pi*w * a.dag() *a
Hi= delta[x]*(a.dag())
H = [H0, [Hi,H1_coeff]]
result = mesolve(H, psi0, tlist, c_ops, [])
numer=expect(n,result.states)
print delta[x], "done"
return numer
有人知道这里有什么问题吗?