@@ -73,16 +73,22 @@ class PythonProcess::Impl
7373 // xeus::xshell_default_runner* p_runner;
7474 xeus::non_blocking_runner* p_runner;
7575
76- QTimer timer;
77-
7876 bool use_jupyter;
7977
78+ #ifdef USE_BLOCKING
79+ QTimer timer;
80+ #else
8081 Runner *qrunner;
82+ #endif
8183};
84+
8285}
8386
8487PythonProcess::Impl::Impl (PythonProcess *_self) : self(_self), interpreter(nullptr ), python(nullptr ),
85- p_runner(nullptr ), timer(_self), use_jupyter(false )
88+ p_runner(nullptr ), use_jupyter(false )
89+ #ifdef USE_BLOCKING
90+ ,timer(_self)
91+ #endif
8692{
8793}
8894
@@ -149,6 +155,8 @@ void PythonProcess::shutdown_impl()
149155 DEBUG_PRINT ();
150156 INFO_STREAM (" shutdown_impl" );
151157 impl->kernel ->get_server ().stop ();
158+ INFO_STREAM (" shutdown_impl::stopped" );
159+
152160 QCoreApplication::quit (); // [TODO] exit choreonoid, is it OK?
153161}
154162
@@ -181,6 +189,7 @@ bool PythonProcess::setupPython()
181189 std::unique_ptr<xeus::xcontext> context = xeus::make_zmq_context ();
182190 Impl::interpreter_ptr interpreter_ (new cnoid_interpreter ());
183191 impl->interpreter = dynamic_cast <cnoid_interpreter *>(interpreter_.get ());
192+ impl->interpreter ->process = this ;
184193 xeus::xconfiguration config = xeus::load_configuration (connection_file);
185194 impl->kernel = Impl::kernel_ptr (new xeus::xkernel (config,
186195 xeus::get_user_name (),
@@ -204,16 +213,18 @@ bool PythonProcess::setupPython()
204213 xpyt::make_python_debugger,
205214 debugger_config));
206215 impl->kernel ->start ();
207- #if 0
216+ #ifdef USE_BLOCKING
208217 // timered non_blocking poll
209218 impl->timer .setInterval (0 );
210219 connect (&(impl->timer ), &QTimer::timeout, this , &PythonProcess::proc);
211220 impl->timer .start ();
212- #endif
221+ #else
222+ // non-blocking using thread
213223 impl->qrunner = new Runner (impl->self );
214224 connect (impl->qrunner , &Runner::sendRequest,
215225 this , &PythonProcess::procRequest, Qt::BlockingQueuedConnection);
216226 impl->qrunner ->start ();
227+ #endif
217228 } else {
218229 std::unique_ptr<xeus::xcontext> context = xeus::make_zmq_context ();
219230 Impl::interpreter_ptr interpreter_ (new cnoid_interpreter ());
@@ -274,6 +285,7 @@ void PythonProcess::procRequest()
274285 proc ();
275286}
276287
288+ #ifndef USE_BLOCKING
277289class Runner ::Impl {
278290public:
279291 Impl () { };
@@ -297,4 +309,4 @@ void Runner::run()
297309 }
298310 }
299311}
300-
312+ # endif
0 commit comments