Fuyukai / Kyoukai

[OLD] A fully async web framework for Python3.5+ using asyncio
https://mirai.veriny.tf
MIT License
298 stars 14 forks source link

Lock url mapping to only one request per time #24

Closed AlbertoOS closed 7 years ago

AlbertoOS commented 7 years ago

Is there a way in Kyoukai to lock a route to only process one request at a time or even using something already in the language?

For example:

@app.route('/status')
async def index(ctx):
    if status_lock.acquire(False):
        # do long operations here
        return json.dumps({'message': 'Complete'})
    else:
        return json.dumps({'message': 'A request on status is already running'})
Fuyukai commented 7 years ago

You can use an asyncio Lock.