mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 17:12:13 -06:00
nice on windows
This commit is contained in:
parent
81f82e8e9f
commit
21e1cd87ca
|
@ -1295,7 +1295,7 @@ class HttpCli(object):
|
||||||
tags[k] = v
|
tags[k] = v
|
||||||
|
|
||||||
if icur:
|
if icur:
|
||||||
taglist = [k for k in self.args.mte.split(",") if k in taglist]
|
taglist = [k for k in vn.flags["mte"].split(",") if k in taglist]
|
||||||
for f in dirs:
|
for f in dirs:
|
||||||
f["tags"] = {}
|
f["tags"] = {}
|
||||||
|
|
||||||
|
@ -1368,7 +1368,7 @@ class HttpCli(object):
|
||||||
ts=ts,
|
ts=ts,
|
||||||
perms=json.dumps(perms),
|
perms=json.dumps(perms),
|
||||||
taglist=taglist,
|
taglist=taglist,
|
||||||
tag_order=json.dumps(self.args.mte.split(",")),
|
tag_order=json.dumps(vn.flags["mte"].split(",")),
|
||||||
have_up2k_idx=("e2d" in vn.flags),
|
have_up2k_idx=("e2d" in vn.flags),
|
||||||
have_tags_idx=("e2t" in vn.flags),
|
have_tags_idx=("e2t" in vn.flags),
|
||||||
logues=logues,
|
logues=logues,
|
||||||
|
|
|
@ -324,11 +324,15 @@ class MTag(object):
|
||||||
for tagname, (binpath, timeout) in parsers.items():
|
for tagname, (binpath, timeout) in parsers.items():
|
||||||
try:
|
try:
|
||||||
cmd = [sys.executable, binpath, abspath]
|
cmd = [sys.executable, binpath, abspath]
|
||||||
if not WINDOWS:
|
args = {"env": env, "timeout": timeout}
|
||||||
|
|
||||||
|
if WINDOWS:
|
||||||
|
args["creationflags"] = 0x4000
|
||||||
|
else:
|
||||||
cmd = ["nice"] + cmd
|
cmd = ["nice"] + cmd
|
||||||
|
|
||||||
cmd = [fsenc(x) for x in cmd]
|
cmd = [fsenc(x) for x in cmd]
|
||||||
v = sp.check_output(cmd, env=env, timeout=timeout).strip()
|
v = sp.check_output(cmd, **args).strip()
|
||||||
if v:
|
if v:
|
||||||
ret[tagname] = v.decode("utf-8")
|
ret[tagname] = v.decode("utf-8")
|
||||||
except:
|
except:
|
||||||
|
|
|
@ -13,6 +13,7 @@ import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
import threading
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
|
import subprocess as sp
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
from .__init__ import WINDOWS
|
from .__init__ import WINDOWS
|
||||||
|
@ -223,8 +224,9 @@ class Up2k(object):
|
||||||
|
|
||||||
_, flags = self._expr_idx_filter(flags)
|
_, flags = self._expr_idx_filter(flags)
|
||||||
|
|
||||||
a = ["\033[36m{}:\033[0m{}".format(k, v) for k, v in sorted(flags.items())]
|
a = "\033[0;36m{}:\033[1;30m{}"
|
||||||
self.log(" ".join(a))
|
a = [a.format(k, v) for k, v in sorted(flags.items())]
|
||||||
|
self.log(" ".join(a) + "\033[0m")
|
||||||
|
|
||||||
reg = {}
|
reg = {}
|
||||||
path = os.path.join(ptop, ".hist", "up2k.snap")
|
path = os.path.join(ptop, ".hist", "up2k.snap")
|
||||||
|
@ -622,6 +624,12 @@ class Up2k(object):
|
||||||
self.log("mtp finished")
|
self.log("mtp finished")
|
||||||
|
|
||||||
def _start_mpool(self):
|
def _start_mpool(self):
|
||||||
|
if WINDOWS and False:
|
||||||
|
nah = open(os.devnull, "wb")
|
||||||
|
wmic = f"processid={os.getpid()}"
|
||||||
|
wmic = ["wmic", "process", "where", wmic, "call", "setpriority"]
|
||||||
|
sp.call(wmic + ["below normal"], stdout=nah, stderr=nah)
|
||||||
|
|
||||||
# mp.pool.ThreadPool and concurrent.futures.ThreadPoolExecutor
|
# mp.pool.ThreadPool and concurrent.futures.ThreadPoolExecutor
|
||||||
# both do crazy runahead so lets reinvent another wheel
|
# both do crazy runahead so lets reinvent another wheel
|
||||||
nw = os.cpu_count() if hasattr(os, "cpu_count") else 4
|
nw = os.cpu_count() if hasattr(os, "cpu_count") else 4
|
||||||
|
@ -646,6 +654,11 @@ class Up2k(object):
|
||||||
|
|
||||||
mpool.join()
|
mpool.join()
|
||||||
self._flush_mpool(wcur)
|
self._flush_mpool(wcur)
|
||||||
|
if WINDOWS and False:
|
||||||
|
nah = open(os.devnull, "wb")
|
||||||
|
wmic = f"processid={os.getpid()}"
|
||||||
|
wmic = ["wmic", "process", "where", wmic, "call", "setpriority"]
|
||||||
|
sp.call(wmic + ["below normal"], stdout=nah, stderr=nah)
|
||||||
|
|
||||||
def _tag_thr(self, q):
|
def _tag_thr(self, q):
|
||||||
while True:
|
while True:
|
||||||
|
|
Loading…
Reference in a new issue