thread conditional code

Robin Becker robin at jessikat.fsnet.co.uk
Sun Apr 15 04:54:59 EDT 2001


In article <mailman.987319642.9319.python-list at python.org>, Tim Peters
<tim.one at home.com> writes
>[Just van Rossum]
>> Now what about when you'd want to be compatible with systems that
>> don't support the thread module?
>
>Seems rarely a problem in practice.  The standard library has some examples,
>though, chiefly tempfile.py.  On a threaded box, that needs a lock to ensure
>that generated filenames are unique.  So, near the bottom of the 2.1 version,
>it tries to import thread, and if that doesn't succeed it creates a
>_DummyMutex class with do-nothing .acquire() and .release() methods.  Thanks
>to the magic of Python not giving a rip about types <wink>, the
>_ThreadSafeCounter class can then pretend it has locks everywhere.
>
>a-platform-without-threads-is-the-same-as-a-platform-with-one-thread-ly
>    y'rs  - tim
>
>
surely this dummying behaviour belongs at the root of the problem ie in
thread rather than scattered everywhere.
-- 
Robin Becker



More information about the Python-list mailing list