Created
May 23, 2017 14:16
-
-
Save vaclavcadek/b432a33fa049683241a12ec549f4ed78 to your computer and use it in GitHub Desktop.
Periodic write to file every second.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sched, time | |
from datetime import datetime | |
s = sched.scheduler(time.time, time.sleep) | |
def read_signal(sc): | |
with open('/home/vasek/Downloads/test.csv', 'a') as log: | |
log.write('{timestamp},{temperature}\n'.format(timestamp=datetime.now(), temperature=23.0)) | |
# do your stuff | |
s.enter(1, 1, read_signal, (sc,)) | |
s.enter(1, 1, read_signal, (s,)) | |
s.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment