From e3cf4ab1e7f50e7f92a84a9da5a23b1ea1356656 Mon Sep 17 00:00:00 2001 From: Askill Date: Thu, 2 Jun 2022 18:48:09 +0200 Subject: [PATCH] saving every 10 sec --- go/server.go | 6 +++--- python/clients.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go/server.go b/go/server.go index c037d7c..4af2963 100644 --- a/go/server.go +++ b/go/server.go @@ -114,8 +114,8 @@ func loadState(img *image, path string) { json.Unmarshal(byteValue, &img) } -func saveState(img *image, path string) { - ticker := time.NewTicker(1 * time.Second) +func saveState(img *image, path string, period time.Duration) { + ticker := time.NewTicker(period * time.Second) for range ticker.C { imgJSON, _ := json.Marshal(img) @@ -143,7 +143,7 @@ func main() { cachePath := "./state.json" loadState(&img, cachePath) - go saveState(&img, cachePath) + go saveState(&img, cachePath, 10) http.HandleFunc("/get", get) http.HandleFunc("/set", set) diff --git a/python/clients.py b/python/clients.py index 2a44497..7c3fcb0 100644 --- a/python/clients.py +++ b/python/clients.py @@ -56,7 +56,7 @@ async def client(): x = pixel(**json.loads(await websocket.recv())) #image[x.x][x.y] = ([y*255 for y in colors[x.color]]) image[x.x][x.y] = ((x.color, x.color, x.color)) - if i% 1000 == 0: + if i% 500000 == 0: cv2.imshow("changes x", image) cv2.waitKey(10) & 0XFF await websocket.send("1")