B
B
bluefasik2022-01-03 18:32:40
Python
bluefasik, 2022-01-03 18:32:40

How to stop a function called from another file?

def start_parser(message):
    if db.get_temp_country(message.from_user.id) == 'pool':
        pool = PoolUi()
        thread_counter = Thread(target=pool.generate_link).start()
        thread_counter = Thread(target=loading_advs(message, params[2])).start()

I have a function in the telegram bot that starts the parser from another "PoolUi" class, how can I make the parser end when the "/stop" command is entered, and the bot can continue to work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2022-01-03
@bluefasik

Pass an Event object to the parser function and set it to complete the execution of the function, and the function must check its state during operation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question