Movatterモバイル変換


[0]ホーム

URL:


thread conditional code

Tim Peterstim.one at home.com
Sun Apr 15 03:26:24 EDT 2001


[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 ensurethat 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.  Thanksto 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


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp