[Qgis-developer] Poor asynchronous performance of Python threads?

Martin Dobias wonder.sk at gmail.com
Fri Feb 18 17:07:46 EST 2011


Hi Charlie

On Wed, Feb 9, 2011 at 6:27 AM, Charlie Sharpsteen <chuck at sharpsteen.net> wrote:
> Hello list,
> I have been playing around with the development branch of IPython (0.11-dev)
> as they have built a PyQt-based console that supports all sorts of awesome
> features like tab-completion, paged browsing of function code and
> docstrings, and Pygments-powered syntax highlighting in addition to the
> normal IPython goodness.  I slapped together a quick plugin that adds an
> IPython-based console to QGIS.  The code is available at:
>     https://github.com/Sharpie/qgis-ipython
> To use it, you will need to install ZeroMQ, pyzmq, pygments and the dev
> version of IPython from:
>     https://github.com/ipython/ipython

Generally the best / easiest way how to make your code available for
testing for others is to upload the plugin at pyqgis.org to the
contributed repository. Requiring development version of ipython would
be however a show stopper for most users...

> The console fires up allright, but unfortunately very, very, very slow.
>  There is about ~1-2 seconds of lag between invoking a command
> and receiving a response.  For comparison, I threw together a minimal PyQGIS
> application that also uses the IPython console:
>     https://gist.github.com/817914
> The PyQGIS version is very snappy and there is no lag.  I suspect the
> difference is due to the PyQt widget is talking to an external IPython
> process through ZeroMQ.  When a command is executed, the console sends a
> message and then a Python thread waits for the response.  With PyQGIS,
> Python is controlling the execution of the entire application.  However,
> when the console is used as a plugin it is running in an embedded
> interpreter and it looks like QGIS takes a while to schedule the execution
> of the Python threads.
> Does anyone have any suggestions for solving or working around this issue?

An interesting issue. Why do you think that IPython uses another
process? Running the console in another process would disable the
communication between QGIS interface and the console - and that is not
really wanted. Maybe you could try to run that code in a profiler to
find out where is the bottleneck.

Martin


More information about the Qgis-developer mailing list