在akka-http中,你可以:
这些都是从http服务器到客户端的背压形式,但两者都是非常低级别的,并且只与您服务器的性能间接相关。
根据服务器看到的请求率,似乎更好的是在http级别进行背压。可能返回429 - 太多请求。 请求率也可以说是对绩效的间接衡量,但似乎比连接数更接近。
这似乎是一个相当合理的事情,但我找不到任何现有的模式。这是我能找到的最接近的参考:https://github.com/akka/akka-http/issues/411
据我所知,最好的方法是抓住Flow
将Route
转换为Route
,并将其插入到具有全球请求率度量的图表中(或者可能是单个处理队列)和一个完全绕过import turtle
import random
import sys
while True:
list = ['report', 'beach', 'mayor', 'score', 'overeat', 'load', 'battery', 'social', 'honor', 'risk']
turns = 10
guesses = ''
err = 0
usedw = random.choice(list)
wn = turtle.Screen()
draw = turtle.Turtle()
length = len(usedw)
print("Welcome to hangman your word is", length, "letters long.")
while turns > 0:
guess = input("Choose a character: ")
guesses += guess;
lengthr = 0
for char in usedw:
if char in guesses:
print (char,)
lengthr += 1;
else:
err += 1;
if err == 1:
draw.goto(0,0)
draw.down()
draw.goto(200,0)
elif err == 2:
draw.up()
draw.goto(0,0)
draw.down()
draw.goto(0,200)
elif err == 3:
draw.up()
draw.goto(0,200)
draw.down()
draw.goto(100,200)
elif err == 4:
draw.up()
draw.goto(100,200)
draw.down()
draw.goto(100,150)
elif err == 5:
draw.up()
draw.goto(100,100)
draw.down()
draw.circle(25)
elif err == 6:
draw.up()
draw.goto(100,100)
draw.down()
draw.goto(100,50)
elif err == 7:
draw.up()
draw.goto(75,90)
draw.down()
draw.goto(125,90)
elif err == 8:
draw.up()
draw.goto(100,50)
draw.down()
draw.goto(75,35)
elif err == 9:
draw.up()
draw.goto(100,50)
draw.down()
draw.goto(125,35)
print("You loose.")
break
if lengthr == length:
print ("You won!")
break
cont = input("Would you like to continue (y/n) ")
if cont == 'y':
print("Alright!")
else:
print("Thanks for playing!")
break
sys.exit()
(通过返回429或其他)的短路。
有更好的想法吗?