Python Forum
Number of documents processed counter in Flask API
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Number of documents processed counter in Flask API
#1
I'm creating a document processing website and the backend is in python using Flask API. I wanted a counter on the bottom of the front end page (in ReactJS) to display how many documents have been processed so far (over lifetime of website) I'm ok just having the website query a route in the flask API to give it the count and display it. I'm not sure the best way to store, query and update the count on the server side each time a document is processed. I can imagine a case where one user is processing a document and current count value is read into memory and is about to update it, but another user already updated it using the same value, then the value gets overwritten by the other user with the wrong count update. So its basically similar to a transaction/concurrency issue in RDBMS.

Should I solve this using optimistic concurrency with a time stamp on a text file? Any other suggestions?
Reply
#2
Hello,

what you may want to do is feed a value like a "1" or so in a queue once another document is procees and handle the counter increment on the other end of the queue. This safetly prevents race conditions, as you kind of seralize the increment.

Gruß, noisefloor
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020