11.24 速率限制
This commit is contained in:
parent
31d49cff94
commit
20a1e0a10d
@ -4,7 +4,7 @@ from functools import wraps
|
||||
|
||||
|
||||
class ConnectionLimiter:
|
||||
def __init__(self, max_connections=10):
|
||||
def __init__(self, max_connections=1):
|
||||
self.semaphore = threading.Semaphore(max_connections)
|
||||
|
||||
def limit_connections(self, f):
|
||||
|
@ -13,7 +13,7 @@ from flask_app.routes.test_zbparse import test_zbparse_bp
|
||||
class FlaskAppWithLimiter(Flask):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.connection_limiter = ConnectionLimiter(max_connections=10)
|
||||
self.connection_limiter = ConnectionLimiter(max_connections=1)
|
||||
def create_app():
|
||||
app = FlaskAppWithLimiter(__name__)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user