import subprocess
result = b''
process = subprocess.Popen(['cmd', '/C', command], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = process.communicate()
if out:
result += out.decode('cp866').encode('utf-8')
if err:
result += err.decode('cp866').encode('utf-8')
print(result)
import time
import threading
def start_stop():
while current_bool:
time.sleep(1)
print("Цикл все еще работает")
current_bool = True
threading.Thread(target=start_stop).start()
time.sleep(3)
current_bool = False