We are trying to use the matlab engine in our QT C++ application, through a PythonQT console. Normal python commands work from within the pythonQT console in our application, however when we attempt to connect to the matlab engine, it hangs at the function call MatlabEngine::waitForMATLAB
(see line 6 of stack trace at the end of the question).
We have a Matlab instance running and its engine is shared by calling matlab.engine.shareEngine
. On the PythonQT console, we connect to it by
eng = matlab.engine.connect_matlab('XXXX')
.
This results in the engine(?) freezing.
Note: We don't have a problem connecting to matlab engine directly from a generic python terminal. We only encounter this problem when we access it from within the PythonQT terminal.
Stack trace:
1 __psynch_cvwait
2 _pthread_cond_wait
3 std::condition_variable::__do_timed_wait(std::unique_lock<std::mutex>&, std::chrono::time_point<std::chrono::system_clock, std::chrono::duration<long long, std::ratio<1l, 1000000000l>>>)
4 std::cv_status std::condition_variable::wait_for<long long, std::ratio<1l, 1000000000l>>(std::unique_lock<std::mutex>&, std::chrono::duration<long long, std::ratio<1l, 1000000000l>> const&)
5 std::future_status std::__assoc_sub_state::wait_until<std::chrono::steady_clock, std::chrono::duration<long long, std::ratio<1l, 1000000000l>>>(std::chrono::time_point<std::chrono::steady_clock, std::chrono::duration<long long, std::ratio<1l, 1000000000l>>> const&) const
6 engine_api::waitMATLAB(unsigned long long, double)
7 MatlabEngine::waitForMATLAB(_object *, _object *)
8 PyEval_EvalFrameEx
9 ___lldb_unnamed_symbol1476$$Python
10 PyEval_EvalFrameEx
11 PyEval_EvalCodeEx
12 ___lldb_unnamed_symbol1476$$Python
13 PyEval_EvalFrameEx
14 PyEval_EvalCodeEx
15 ___lldb_unnamed_symbol1476$$Python
16 PyEval_EvalFrameEx
17 PyEval_EvalCodeEx
18 ___lldb_unnamed_symbol1476$$Python
19 PyEval_EvalFrameEx
20 PyEval_EvalCodeEx
21 PyEval_EvalCode
22 ___lldb_unnamed_symbol1599$$Python
23 PyRun_StringFlags
24 PythonQtScriptingConsole::executeCode(QString const&)
25 PythonQtScriptingConsole::executeLine(bool)
26 PythonQtScriptingConsole::keyPressEvent(QKeyEvent *)
27 QWidget::event(QEvent *)
28 QFrame::event(QEvent *)
29 QAbstractScrollArea::event(QEvent *)
30 QTextEdit::event(QEvent *)
31 QApplicationPrivate::notify_helper(QObject *, QEvent *)
32 QApplication::notify(QObject *, QEvent *)
33 QCoreApplication::notifyInternal2(QObject *, QEvent *)
34 ___lldb_unnamed_symbol542$$QtWidgets
35 QApplicationPrivate::notify_helper(QObject *, QEvent *)
36 QApplication::notify(QObject *, QEvent *)
37 QCoreApplication::notifyInternal2(QObject *, QEvent *)
38 QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *)
39 QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)
40 QWindowSystemInterface::flushWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)
41 ___lldb_unnamed_symbol405$$libqcocoa.dylib
42 ___lldb_unnamed_symbol406$$libqcocoa.dylib
43 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:]
44 -[NSWindow(NSEventRouting) sendEvent:]
45 ___lldb_unnamed_symbol169$$libqcocoa.dylib
46 ___lldb_unnamed_symbol152$$libqcocoa.dylib
47 -[NSApplication(NSEvent) sendEvent:]
48 ___lldb_unnamed_symbol583$$libqcocoa.dylib
49 -[NSApplication run]
50 ___lldb_unnamed_symbol505$$libqcocoa.dylib
51 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)
52 QCoreApplication::exec()
53 main
54 start
I have an open question on this in the Matlab forums, with no answers as of now.
Any help or pointers is appreciated :)
NT