I recently had to use a timer in a Python-program, and happened to run into a problem with the time.clock() function, which is supposed to be the most accurate [more accurate than time.time()]. The problem was, I found not the accuracy, but rather that clock() seemed to function poorly, when some blocing code, ie. socket.recv() and socket.send() was involved.
The problem:
import time
tstart = time.clock()
elapsed = time.clock() - tstart
The solution:
from datetime import datetimetstart = datetime.now() elapsed = datetime.now() - start elapsed.seconds
Worked just perfectly.