neonize icon indicating copy to clipboard operation
neonize copied to clipboard

Sorry how can I stop the program ?

Open rayenking opened this issue 1 year ago • 3 comments
trafficstars

rayenking avatar Mar 10 '24 10:03 rayenking

To stop a program , you can use the 'signal' module to catch interrupt signals (such as CTRL+C) and set an event defined in 'neonize.event'. Here is a clearer explanation of how it works:

First, import 'event' from 'neonize.event' and the 'signal' module:

from neonize.event import event
import signal

Next, define the 'interrupted' function that will set the event when an interrupt signal is received:

def interrupted(*_):
    event.set()

Register this function as the signal handler for SIGINT (keyboard interrupt):

signal.signal(signal.SIGINT, interrupted)

With this explanation, when you press CTRL+C, the 'interrupted' function will be called, which will set the 'event' from 'neonize.event'. You can then check the status of this event in the program loop to determine if the program should stop. Make sure to handle any necessary cleanup before the program fully stops. https://github.com/krypton-byte/neonize/blob/master/examples/basic.py

krypton-byte avatar Mar 10 '24 11:03 krypton-byte

I just run the example/basic.py and first I thought it was my windows and I try with my Ubuntu Server it still running cannot interrupted idk why

rayenking avatar Mar 10 '24 13:03 rayenking

I've been confused so I create this command wkwk :v

image

rayenking avatar Mar 10 '24 13:03 rayenking