I have data coming in from an outside source (serial port in this case) roughly every 2.5 seconds.
I want to store ( in mysql) a sample of this data every 5 minutes, not every 2.5 seconds.
How would i implement this in python?
One can probably not use a sleep function since this will stop the rest of the script.
I have data coming in from an outside source (serial port in this case)
Share
Check how much time has passed since the last save for each incoming event, and update the last-save timestamp after each save:
If your application is multithreaded or multiprocessing you should also look into implementing a lock in the
SaveEventfunction to avoid concurrent saves.