[Patches] [ python-Patches-622537 ] dummy_thread.py implementation
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 13 Oct 2002 00:07:59 -0700
Patches item #622537, was opened at 2002-10-13 00:07
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=622537&group_id=5470
Category: Library (Lib)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Brett Cannon (bcannon)
Assigned to: Nobody/Anonymous (nobody)
Summary: dummy_thread.py implementation
Initial Comment:
As mentioned in Zack Weinberg's Python-dev thread, "A
few lessons from the tempfile.py rewrite", it was
brought up that not having thread in all distributions
is a pain because you have to write around instances of
it not existing. Guido suggested the compromise of
having a dummy_thread.py so that one could do:
try:
import thread as _thread
except ImportError:
import dummy_thread as _thread
This is specific comment can be found at
http://mail.python.org/pipermail/python-dev/2002-August/027985.html
.
Well, I decided to implement dummy_thread.py . I have
tested it against test_thread.py and test_threading.py
by editing the files locally to import dummy_thread as
thread. All tests did pass.
The only thing that is not necessarily straight-forward
in the implementation is that for non-blocking
lock.acquire() calls, the code actually checks to see
if the lock is available; blocking calls just
automatically acquire the lock since blocking when
there is not real threading would not big good. =) It
was also to appease the assert demons in threading.py
for Condition objects since Condition._is_owned() did
not like having lock.acquire() always succeed.
As for adding regression tests, one could just run
test_thread.py specifically against dummy_thread.py .
The tougher test, though, was getting test_threading.py
to work with threading.py importing dummy_thread.
I am not, as of this exact moment, uploading any
patches to add regression tests since I wrote this on a
whim and I am leaving for vacation on 2002-10-14. I
will be back by November 1, though, and I can try to
come up with how to integrate regression tests then if
no one has beaten me to it.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=622537&group_id=5470