'Implement locks for GET request distinct by query parameter in Flask application
I have setup a Flask server that serve a GET request like
@app.route('/foo', methods=['GET'])
def foo():
id = request.args.get('key')
"""
data = list_new_data(id)
sync_new_data(data)
mark_synced_data_as_read()
"""
return 'success'
However, often time /foo?key=123 can be requested multiple times and if they happen to be running concurrently, chances are we will be duplicating new data. I'm wondering if there's a way to take out a lock distinct by /foo?key123 and fail or queue any subsequence /foo?key=123 coming after it?
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
