Ask Your Question
1

html processing delay

asked 2012-01-08 01:41:26 +0100

Eugene gravatar image

updated 2012-01-09 16:14:06 +0100

Hello!

Could anyone please explain me why this code:

for i in range(7):
    html('<script>alert("Text %g");</script>' % i)
    time.sleep(1)

gives no alert messages before cell completely calculated? Is there any way to force immediate output processing?

Another example:

for x in range(10):
    html('$\\rho$')
    time.sleep(1)

This code gives immediate output as latex-commands like:

\rho
\newcommand{\Bold}[1]{\mathbf{#1}}

and after cell calculation is done it shows the correct symbols instead of latex-commands.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-01-09 15:10:01 +0100

Mike Witt gravatar image

updated 2012-01-09 15:10:35 +0100

To give periodic reports about what my code is doing, I sometimes do something like this:

print('About to start something')
os.system('date')
sys.stdout.flush()
#
# The code that does the thing
#
print('Finished doing something'
os.system('date')
sys.stdout.flush()

The "flush" business makes the output actually happen, rather than getting queued up for later. I think this works in both the command line and the notebook (I mostly use the command line).

edit flag offensive delete link more

Comments

Thanks for reply! But the flush method is not something that works here. The problem is in processing output not printing it. See new example posted - there is output, but this is raw output, not processed by jsmath or browser itself.

Eugene gravatar imageEugene ( 2012-01-09 16:15:33 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-01-08 01:41:26 +0100

Seen: 767 times

Last updated: Jan 09 '12