我有一个带有简单ThreadedHTTPServer的python脚本。我在linux服务器上运行它,一旦我启动脚本,在任何请求到来之前,我看到很多线程(~40)。
如何设置服务器启动的线程数的最大值?
如何在请求到达时设置服务器将使用的线程数的最大值?
def add_score(): # let me rename this to lowercase
ans = [] # lets put the new file content here
with open("users.txt") as myFile:
for num, line in enumerate(myFile, 1):
if name in line:
line_found = num
# break -- you don't want to break, you want your 25 to be 26
*things, num = line.split(": ") # extract whats after the last ': '
things.append(int(num)+1)
line = ": ".join(things) # change the line
ans.append(line)
print("".join(ans), file=open("users.txt", mode='w'))