This is my script
import threading
import os
class Say(threading.Thread):
def __init__(self, cmd):
super(Say, self).__init__()
self.cmd = cmd
def run(self):
os.system(self.cmd)
t1 = Say("afplay /System/Library/Sounds/Tink.aiff")
t2 = Say("afplay /System/Library/Sounds/Ping.aiff")
t1.start()
print("a")
t2.start()
print("b")
It appears that both starts are executed immediately. However, the sounds are not played in parallel but one after the other.
When running the following shell script
afplay /System/Library/Sounds/Tink.aiff &
afplay /System/Library/Sounds/Ping.aiff &
both sounds play at the same time. What makes Python run the commands sequentially instead of parallel?
I'm using Big Sur with with the standard Python (2.7).