mirror of https://github.com/Askill/r_place.git
saving every 10 sec
This commit is contained in:
parent
14584c41a0
commit
e3cf4ab1e7
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in New Issue