websocketd icon indicating copy to clipboard operation
websocketd copied to clipboard

make variable persistent on close/open connection

Open vincenthure opened this issue 3 years ago • 2 comments

Hello, My setup is Busybox httpd as web server webscocketd –port 8080 python3 pilot. py In my python program I have global variable and I can modify them with button in my web page It’s working very good , bi-directional so I can show the value on the web page. My problem is when I reload my web page the variable are set to their default value. How can I do to make this variable persistent on open/close connection? Vincent

vincenthure avatar Dec 03 '21 12:12 vincenthure

Every connection spins another copy of your python program. In order to save anything between them you need some sort of storage. This could be as simple as small local file or as complex as external database (memcached/redis/dynamodb/mysql - your call)

I don't know much about python but according to docs it can do mmap too: https://docs.python.org/3/library/mmap.html could be interesting choice if you are on system that supports it.

asergeyev avatar Dec 04 '21 03:12 asergeyev

Thank you for your help. I finaly choice to install a small SQLite3 database and It work fine.

vincenthure avatar Dec 11 '21 16:12 vincenthure