Tim Peters wrote:
> Because the program is buggy: synchronizing threads isn't a "do it if
> you feel like it" thing, it's essential to correct threaded behavior.
> If you're going to show students bad thread practice, they're going to
> get mysteries a lot deeper and more damaging than this one <0
[Michele Simionato]
> Thank you for your replies Jeff & Tim. The snippet I submitted is
> unfortunate, since I was writing an example (for a Python course I am
> going to give in September) to show that you cannot reliably assume
> that you will get exactly 9 dots, because of the limitations of 'sl
Thank you for your replies Jeff & Tim. The snippet I submitted is
unfortunate,
since I was writing an example (for a Python course I am going to give
in
September) to show that you cannot reliably assume that you will get
exactly 9 dots, because of the limitations of 'sleep'. Mindlessly, I
have
cut
[Michele Simionato]
> I am getting a strange error with this script:
>
> $ cat doctest-threads.py
> """
> >>> import time, threading
> >>> def example():
> ... thread.out = []
> ... while thread.running:
> ... time.sleep(.01)
> ... thread.out.append(".")
> >>> thread = threa
I don't see the problem with your doctest usage, but what makes you believe that
the code you show below produces exactly 9 dots?
strangely enough, re-working the code to this
>>> import time, threading
>>> def example():
... thread.out = []
... for i in range(9): thread.out.append(".")
>>
I am getting a strange error with this script:
$ cat doctest-threads.py
"""
>>> import time, threading
>>> def example():
... thread.out = []
... while thread.running:
... time.sleep(.01)
... thread.out.append(".")
>>> thread = threading.Thread(None, example)
>>> thread.run