Skip to content

(Keyboard)Interupt doesn't get propagated correctly #4

@donmahallem

Description

@donmahallem

The following will run indefinitely. If an KeyboardInterupt is issued the WebSocket-Transmission will stop but the program will not end. When logging with Verbosity.ALL it will show no further transmission after the first KeyboardInterupt but the whole script won't shutdown.

from pyghthouse import Pyghthouse,VerbosityLevel
from login import username, token
from random import randint
import colorsys
p = Pyghthouse(username, token)
p.start()

img = Pyghthouse.empty_image()
p.set_image(img)
dir_factor=10
dirs=[(0,1),(1,0),(0,-1),(-1,0)]
cur=(0,0)
cur_hue=0
while True:
    cur_x,cur_y=cur
    while True:
        rand_dir_x,rand_dir_y=dirs[randint(0,3)]
        next_x,next_y=cur_x+rand_dir_x,cur_y+rand_dir_y
        if next_x>=0 and next_y>=0 and next_x<28 and next_y<14:
            break
    next_hue=(cur_hue+1)%360
    img[next_y][next_x]=tuple(round(i * 255) for i in colorsys.hsv_to_rgb(next_hue/360.0,1,1))
    cur=(next_x,next_y)
    cur_hue=next_hue
    p.set_image( img)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions