Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
donmahallem opened this issue Dec 19, 2024 · 0 comments
Open

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

donmahallem opened this issue Dec 19, 2024 · 0 comments

Comments

@donmahallem
Copy link

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant