python - Pass variables from one script to another and save to file every X minute(s) -


i have spent hours pouring through other questions , have not been able find solution problem.

i have program calls python script argument @ events. every time script called need increment variable 1 , save file. tried doing directly (open, increment one, , save file) every time called had loss of precision due how fast calls being made @ times. trying figure out how have script run , count, every x minutes write count file. have write file part working great, need how keep variable count , write file every x minutes.

i tried doing single script using threading every time called global variable declarations overwrite count. ahead of time.

i read through query , researched on internet too. prior describing research had couple of queries:

  1. is main program calls python script callee.py python script? if yes, main script written or have permission change source code in main script?
  2. do require call python script asynchronous?

i ask because in case main program python script written or can make changes source code , call callee.py not needed asynchronous can use subprocess.call method wait callee.py complete. within callee.py, have open file-update count-save file operation have developed. since, calls synchronous in nature wont have worry missed or incorrect counts.

however, in case approach main program needs call callee.py asynchronusly or main non-python program (an exe) have ensure synchronized update file storing counts. query how asked on stack overflow. also, please refer below link on cross platform file locking in python more information on how can lock file, update , release lock.

this approach work whenever there multiple executions script within main program in asynch fashion.

i hope points in direction of solution


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -