【发布时间】:2013-08-14 09:35:17
【问题描述】:
我试图使用两个线程从 python 程序中调用 Octave 函数。我的八度代码只是为了看看它是如何工作的-
testOctave.m
function y = testOctave(i)
y = i;
end
而python程序只是试图调用它
from oct2py import octave
import thread
def func(threadName,i) :
print "hello",threadName // This printf works
y = octave.testOctave(i)
print y // This is ignored
print 'done' // This is ignored
print 'exiting' // This is ignored
try:
thread.start_new_thread( func, ("Thread-1", 100 ) )
thread.start_new_thread( func, ("Thread-2", 150 ) )
except:
print "Error: unable to start thread"
程序在没有任何错误的情况下退出,但在上述函数中,仅执行第一次打印,所有在 octave 调用之后的打印都被两个线程忽略。发生这种情况有什么原因吗?我该怎么做才能让它发挥作用?
该程序没有做任何特别的事情,我只是想弄清楚如何使用 oct2py
【问题讨论】:
标签: python multithreading octave oct2py