I have spent hours pouring through other questions and have not been able to find a solution to my problem.
I have a program that calls my python script with an argument at certain events. Basically every time my script is called I need it to increment a variable by one and save it to a file. I tried doing it directly (open, increment by one, and save file) every time it was called but I had a loss of precision due to how fast the calls were being made at times. I am trying to figure out how to have a script run and just count, then every X minutes write the count to a file. I have the write to file part working great, I just need help with how to keep up with the variable count and write it to a file every X minutes.
I tried doing this with a single script using threading but every time it was called the global variable declarations would overwrite the count. Thanks for the help ahead of time.