macro plots in spock do not appear until macro finishes (SF#297)
Created by: sf-migrator-bot
Confirmed with ipython version 1.0.0.
This is difficult to observe with the sardana/macroserver/macros/examples/plotting.py macros since they finish right after the plot functions are called, but the attached example shows this misbehavior.
One can reproduce it executing the "plot_macro" from the attached "test_plot.py" module.
I suspect that this has to do with Qt integration in the ipython (spock).
Macros are being executed as a synchronous magic functions in the ipython. This means that the ipython main thread is blocked until the macro is finished. The plotting feature in sardana is implemented using the Tango events mechanism (RecordData attribute). So the Tango event's callback emits a Qt signal, and the connected slot is responsible for executing the plotting functions (matplotlib). I suspect that the Qt EventLoop is not executed while the main thread is blocked, hence the slots are not called. The plotting functions are successfully called after the macro finishes.
This theory could lack some details, or could not use appropriate naming. Certainly it needs deeper analysis of the ipython and Qt core concepts. This theory could be confirmed by executing a macro in asynchronous mode (kwargs['synch'] = False in SpockBaseDoor._runMacromode metod.
Reported by: reszelaz ( http://sf.net/u/zreszela )
Original Ticket: sardana/tickets/297