Python Forum
Question on a code's design - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Question on a code's design (/thread-17213.html)



Question on a code's design - ebolisa - Apr-02-2019

Hi,

I'm designing a button-less clock using a Raspberry with a SD card and I'm doing it this way:

With a php code I create a data.json settings file where I store alarm time, brightness level, etc.

then with a python code, I load the libraries, read the settings and display time. If the time matches, sounds an alarm.

Because the code displays the time every seconds, the settings file (data.json) is constantly read.

My question is, if reading the data file so many times per minutes and thus per year, is it affecting the SD card's life or is there a better way of doing it?

TIA


RE: Question on a code's design - Gribouillis - Apr-03-2019

I see at least 2 other ways to do it
  1. Write the json file on a ramdisk instead of the SD card, or
  2. Start a server with the python script, such as a web server or a xmlrpc server or a simple socketserver, then attempt to connect this server from the php script and send the data instead of writing them in a json file.