In Python
how to get what block of script is running just right now, runtime?
print a() #takes couple of seconds, 3s
print b() #takes couple of seconds, 3s
pass
print c() #takes couple of seconds, 4s
print d(), \
t,y,u,i,o #takes couple of seconds, 4s
print z
So to know (report) what is running in the second 7th, for example.
report(7s): print c()
EDIT:
We keep the above as it is to justify the comments given ;) however below we describe our questions in more details.
A Python
code is being executed line by line (or better block by block). See for example:
in code.py
:
for i in xrange(10000000): #assume this will take some seconds
pass
print 'something'
#another time consuming job
for j in xrange(10000000): #assume this will also take some seconds
pass
print 'another thing'
We were thinking having a time thread which samples every 5 seconds to print (i.e., report) where we are in the code in runtime. So to have every 5 seconds printing what just happening during the execution.
Example output:
>>> 00:05 in progress: "for i in xrange(10000000):..."
>>> 00:10 in progress: "for i in xrange(10000000):..."
>>> 00:15 in progress: "for j in xrange(10000000):..."
...