11.24 速率限制

This commit is contained in:
zy123 2024-11-25 10:27:46 +08:00
parent 31d49cff94
commit 20a1e0a10d
2 changed files with 2 additions and 2 deletions

View File

@ -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):

View File

@ -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__)