mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
support winxp
This commit is contained in:
parent
5b708c45ed
commit
ae197b2183
|
@ -86,8 +86,11 @@ def main():
|
|||
thr.daemon = True
|
||||
thr.start()
|
||||
|
||||
try:
|
||||
while True:
|
||||
time.sleep(9001)
|
||||
except:
|
||||
print("bye")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -121,7 +121,7 @@ class HttpCli(object):
|
|||
for ln in form_segm[1:]:
|
||||
self.log(ln)
|
||||
|
||||
fn = "/dev/null"
|
||||
fn = os.devnull
|
||||
fn0 = "inc.{0:.6f}".format(time.time())
|
||||
|
||||
files = []
|
||||
|
|
|
@ -37,8 +37,11 @@ class MpWorker(object):
|
|||
thr.daemon = True
|
||||
thr.start()
|
||||
|
||||
try:
|
||||
while True:
|
||||
time.sleep(9001)
|
||||
except:
|
||||
self.logw("bye")
|
||||
|
||||
def log(self, src, msg):
|
||||
self.q_yield.put(["log", src, msg])
|
||||
|
|
|
@ -8,8 +8,8 @@ import threading
|
|||
from datetime import datetime, timedelta
|
||||
import calendar
|
||||
|
||||
from .__init__ import *
|
||||
from .msgsvc import *
|
||||
from .mpsrv import *
|
||||
|
||||
|
||||
class TcpSrv(object):
|
||||
|
@ -20,6 +20,8 @@ class TcpSrv(object):
|
|||
"""
|
||||
|
||||
def __init__(self, args):
|
||||
self.args = args
|
||||
|
||||
self.log_mutex = threading.Lock()
|
||||
self.msgsvc = MsgSvc(self.log)
|
||||
self.next_day = 0
|
||||
|
@ -46,12 +48,7 @@ class TcpSrv(object):
|
|||
|
||||
self.log("root", "listening @ {0}:{1}".format(bind_ip, bind_port))
|
||||
|
||||
if args.j == 0:
|
||||
self.log("root", "multiprocessing disabled")
|
||||
httpsrv = HttpSrv(args, self.log)
|
||||
else:
|
||||
httpsrv = MpSrv(args, self.log)
|
||||
|
||||
httpsrv = self.create_server()
|
||||
while True:
|
||||
if httpsrv.num_clients() >= args.nc:
|
||||
time.sleep(0.1)
|
||||
|
@ -60,6 +57,52 @@ class TcpSrv(object):
|
|||
sck, addr = srv.accept()
|
||||
httpsrv.accept(sck, addr)
|
||||
|
||||
def check_mp_support(self):
|
||||
vmin = sys.version_info[1]
|
||||
if WINDOWS:
|
||||
if PY2:
|
||||
# ForkingPickler doesn't support winsock
|
||||
return False
|
||||
elif vmin < 4:
|
||||
return False
|
||||
else:
|
||||
if not PY2 and vmin < 4:
|
||||
return False
|
||||
|
||||
try:
|
||||
# fails on py3.3, works on py2.7
|
||||
from multiprocessing.reduction import ForkingPickler
|
||||
except:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def create_server(self):
|
||||
if self.args.j == 0:
|
||||
self.log("root", "multiprocessing disabled by argument -j 0;")
|
||||
return self.create_threading_server()
|
||||
|
||||
if not self.check_mp_support():
|
||||
if WINDOWS:
|
||||
self.log("root", "need python 3.4 or newer for multiprocessing;")
|
||||
else:
|
||||
self.log("root", "need python 2.7 or 3.4+ for multiprocessing;")
|
||||
|
||||
return self.create_threading_server()
|
||||
|
||||
return self.create_multiprocessing_server()
|
||||
|
||||
def create_threading_server(self):
|
||||
from .httpsrv import HttpSrv
|
||||
|
||||
self.log("root", "cannot efficiently use multiple CPU cores")
|
||||
return HttpSrv(self.args, self.log)
|
||||
|
||||
def create_multiprocessing_server(self):
|
||||
from .mpsrv import MpSrv
|
||||
|
||||
return MpSrv(self.args, self.log)
|
||||
|
||||
def log(self, src, msg):
|
||||
now = time.time()
|
||||
if now >= self.next_day:
|
||||
|
|
Loading…
Reference in a new issue