This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nullnil
Recipients nullnil
Date 2009-08-21.07:28:26
SpamBayes Score 5.5653766e-07
Marked as misclassified No
Message-id <1250839709.71.0.595068140402.issue6750@psf.upfronthosting.co.za>
In-reply-to
Content
# Bug Description
In a multi-threaded environment, the Win32 Python3000 built-in function
"print" may give the output several times.

# How to Reproduce:
import threading
event = threading.Event()
class Test(threading.Thread):
    def __init__(self, ord):
        super().__init__()
        self.ord = ord
    def run(self):
        event.wait()
        print('Hello, world!', self.ord)
threads = tuple(map(Test, range(8)))
tuple(map(lambda thread: thread.start(), threads))
event.set()
tuple(map(lambda thread: thread.join(), threads))
# EOF

# Problem Observed
[The first run, 0 is doubled]
Hello, world! 0
Hello, world! 0
Hello, world! 1
Hello, world! 2
Hello, world! 3
Hello, world! 4
Hello, world! 5
Hello, world! 6
Hello, world! 7

[the second run, 1 and 7 are doubled]
Hello, world! 1
Hello, world! 1
Hello, world! 2
Hello, world! 3
Hello, world! 4
Hello, world! 5
Hello, world! 6
Hello, world! 7
Hello, world! 7
Hello, world! 0

# Expected Result
Each thread gives ONE AND ONLY ONE output.
OR
State this as The Expected Behavior, document it and ask the user to
write something such as critical section.
History
Date User Action Args
2009-08-21 07:28:29nullnilsetrecipients: + nullnil
2009-08-21 07:28:29nullnilsetmessageid: <1250839709.71.0.595068140402.issue6750@psf.upfronthosting.co.za>
2009-08-21 07:28:27nullnillinkissue6750 messages
2009-08-21 07:28:26nullnilcreate