krypton-byte / neonize

whatsapp automation library, written in python
http://krypton-byte.me/neonize/
Apache License 2.0
70 stars 17 forks source link

Sorry how can I stop the program ? #19

Open rayenking opened 8 months ago

krypton-byte commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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

image