From 1b2be86ea5677f58a2ddc8f0369556a330149236 Mon Sep 17 00:00:00 2001 From: none Date: Mon, 26 Feb 2024 12:34:32 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B2=D0=BE=D0=B4=20?= =?UTF-8?q?=D0=BD=D0=B0=20threading,=20multiprocessing=20=D0=BD=D0=B5=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BF=D1=83=D1=81=D0=BA=D0=B0=D0=B5=D1=82=D1=81?= =?UTF-8?q?=D1=8F=20=D0=B2=20Windows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/proxy.py b/proxy.py index 89ef17a..42511c4 100644 --- a/proxy.py +++ b/proxy.py @@ -1,6 +1,5 @@ from os import system, name -#from threading import Thread -from multiprocessing import Process +from threading import Thread from time import sleep global http_out ; http_out = None @@ -21,28 +20,28 @@ def proxy_serv(port): def watch_http(port): - run = Process(target=proxy_http, args=(port,)) + run = Thread(target=proxy_http, args=(port,)) run.start() global http_out while True: # Если команда вышла - if http_out: - run.terminate() + if http_out or not run.is_alive(): + run.join(1) http_out = None - run = Process(target=proxy_http, args=(port,)) + run = Thread(target=proxy_http, args=(port,)) run.start() sleep(1) def watch_serv(port): - run = Process(target=proxy_serv, args=(port,)) + run = Thread(target=proxy_serv, args=(port,)) run.start() global serv_out while True: - if serv_out: - run.terminate() + if serv_out or not run.is_alive(): + run.join(1) serv_out = None - run = Process(target=proxy_serv, args=(port,)) + run = Thread(target=proxy_serv, args=(port,)) run.start() sleep(1)