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

Sorry how can I stop the program ? #19

Open
rayenking opened this issue Mar 10, 2024 · 3 comments
Open

Sorry how can I stop the program ? #19

rayenking opened this issue Mar 10, 2024 · 3 comments

Comments

@rayenking
Copy link

No description provided.

@krypton-byte
Copy link
Owner

krypton-byte commented Mar 10, 2024

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

@rayenking
Copy link
Author

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
Copy link
Author

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

image

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

2 participants