Skip to content
Advertisement

Is it possible to set a jupyter notebook chunk to run with a certain delay after the previous one?

I have the following 2 chunks. Once the first chunk gets executed in python it seems to me that it takes time for the stored procedure to execute in sql. Before that is done, however, python moves immediately to next chunk. Is it possible to delay running of the next chunk by say 5 minutes?

gmd_connection.autocommit=True

# create cursor
cursor = gmd_connection.cursor()

query='EXEC sm.spSecuritiesCreate'

cursor.execute(query)
# close cursor
cursor.close()
# create cursor
cursor = gmd_connection.cursor()

query='EXEC sm.spSolsteinSecuritiesMap'

cursor.execute(query)

# close cursor
cursor.close()

#close connection
gmd_connection.close()

Advertisement

Answer

I’m not sure if Jupyter supports this directly, but you can just add time.sleep(n) as the first line in the block you want to have a delayed start. Here’s the reference.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement