import queue
import re
import subprocess
import sys
import threading
import time
import chardet
from typing import List
class PMProcess():
def __init__(self, args: List[str]):
self.terminate = False
self.q = queue.Queue()
self.on_error_received = lambda error: print(error)
self.args = args
self.process = subprocess.Popen(self.args,
stdin=subprocess.PIPE,
shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
self.to = threading.Thread(
target=self.enqueue_stream, args=(
self.process.stdout, self.q, 1))
self.te = threading.Thread(
target=self.enqueue_stream, args=(
self.process.stderr, self.q, 2))
self.tp = threading.Thread(target=self.consoleLoop)
self.to.setDaemon(True)
self.te.setDa
Python练手代码段(2020.11.11)
最新推荐文章于 2024-04-08 09:11:14 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)