diff options
author | Anthony Wang | 2022-10-03 00:08:58 -0400 |
---|---|---|
committer | Anthony Wang | 2022-10-03 00:08:58 -0400 |
commit | f710490b4f78c70ffb631a8af9996d5736a14853 (patch) | |
tree | ecfbf115dc0f215c65aa278474fc7ddf7a789f45 | |
parent | 9b9c2d307ef9f1dc86ba154befd98c4f3a7c5b59 (diff) |
Use subprocess.Popen
-rw-r--r-- | backend/app.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/backend/app.py b/backend/app.py index b6ff459..f983eff 100644 --- a/backend/app.py +++ b/backend/app.py @@ -1,6 +1,7 @@ from flask import Flask from threading import Thread import os +import subprocess app = Flask(__name__) @@ -8,10 +9,11 @@ app = Flask(__name__) threadFlag = True def playFunction(freq): global threadFlag - os.system("beep -f"+ freq+" -l 100000 &") + p = subprocess.Popen(["beep", "-f", freq, "-l", "100000"]) while not threadFlag: pass #print("beep -f %f" % (freq)) + os.kill(p.pid, 15) thread2 = 0 tc = 0 @@ -35,7 +37,6 @@ def freq2(freq2): global threadFlag global thread2 threadFlag = True - thread2.stop() return("200") if __name__ == "__main__": @@ -43,4 +44,3 @@ if __name__ == "__main__": -
\ No newline at end of file |