Recommended way to fix core python distribution issues in your own apps?

Russell Warren russandheather at gmail.com
Mon Jun 19 17:35:05 EDT 2006


I've got a case where I need to tweak the implementation of a default
python library due to what I consider to be an issue in the library.

What is the best way to do this and make an attempt to remain
compatible with future releases?

My specific problem is with the clock used in the threading.Event and
threading.Timer.  It currently uses time.time, which is affected by
changes in system time.  eg: if you change the system clock somehow at
some time (say, with an NTP broadcast) you may get a surprise in the
timing of your code execution.

What I do right now is basically this:

import sys
import time
import threading
if sys.platform == 'win32':
  threading._time = time.clock

in which case I'm simply forcing the internal clock used in the
Event/Timer code to use a time-independent performance timer rather
than the system time.

I figured this is a much better way to do it than snagging a private
copy of threading.py and making a direct change to it, but am curious
if anyone has a better way of doing this type of thing?  For example, I
have no way of guaranteeing that this hack will work come a change to
2.5 or later.

Thanks,
Russ




More information about the Python-list mailing list