import winsound import threading import time def play0(): winsound.PlaySound('SystemExclamation', winsound.SND_ALIAS) def play1(): winsound.PlaySound('SystemHand', winsound.SND_ALIAS | winsound.SND_NOWAIT) thread = threading.Thread(target=play0) thread.start() # Just to provide more certainty that the thread is actually already # playing the sound when we call play1() below. time.sleep(0.1) # This plays a sound _after_ the thread is finished playing the sound, # due to the fact that WinAPI's PlaySound() queues the play requests. play1() # From the MSDN docs on SND_NOWAIT, it's not clear what a "busy # driver" means. For example, can every process, or even every thread, # have a different state of the driver? That is, can the driver appear # busy in one process, and idle in another? # # Anyway, before we called play1(), the driver should be busy, because # of the thread that calls play0(). Thus, if the winsound.SND_NOWAIT # flag indeed makes winsound.PlaySound() return immediately because of # the busy driver, then the sound specified in play1() should not play # (but it in fact does, at least on modern Windows platforms). # # Hence, the Python documentation should be updated to state that the # winsound.SND_NOWAIT flag is not supported on modern Windows # platforms, just as the documentation states this for # winsound.SND_PURGE.