[IPython-dev] messaging protocol
ellisonbg at gmail.com
Mon Apr 11 12:34:23 EDT 2011
On Mon, Apr 11, 2011 at 3:17 AM, Jason Grout
<jason-sage at creativetrax.com> wrote:
> On 4/11/11 12:28 AM, Brian Granger wrote:
>> Any traffic (stdout, stderr, display hook) that is
>> sent out over the PUB channel is send*immediately*. This is required
>> so that the users sees these things in real time as the code is
>> executed, not after.
> Remember that the use-case here is that only the last pyout output is
> displayed, so it seems perfectly reasonable for the displayhook to delay
> sending until after the cell is executed. This is not the use-case
> where we want interactive pyout output from every command.
Yes, you are right. If we only trigger pyout/dhook on the last block
the code will most likely be done executing (basically no delay).
> The one case where I see a possible problem is when you have something like:
> print "done"
> Then I suppose the pyout output would either be the pyout of a, or the
> pyout "None" (I don't know offhand which it would be). If it was the
> pyout of a, then the pyout would be sent after the printed stdout
> output, which would seem weird.
Fernando and I spent some time last night looking at various options
and we think the best option is what Thomas has in this branch:
The idea is that dhook will only be displayed for:
* The last block in a multiblock expression.
* And only if that block is an ast.Expr.
This means that the following will trigger the dhook:
a # if a is defined...
But the following won't:
for i in range(10):
This will result in dhook being called either 0 or 1 times. To make
this decision, we need the ast information, so it makes sense to
handle this in the splitter.
> IPython-dev mailing list
> IPython-dev at scipy.org
Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger at calpoly.edu and ellisonbg at gmail.com
More information about the IPython-dev