First time here? Check out the FAQ!

Ask Your Question
1

html processing delay

asked 13 years ago

Eugene gravatar image

updated 13 years ago

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 13 years ago

Mike Witt gravatar image

updated 13 years ago

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).

Preview: (hide)
link

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 ( 13 years ago )

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: 13 years ago

Seen: 836 times

Last updated: Jan 09 '12