у меня есть поток
class InstaBot(QtCore.QThread):
def __init__(self,username,password,browser,amount,media_per,follow,like,comment_count,comment,user,user_count,following,liking,
commenting, parent = None):
super(InstaBot, self).__init__(parent)
self.username = username
self.password = password
self.browser = browser
self.amount = int(amount)
self.media_per = int(media_per)
self.follow = int(follow)
self.like = int(like)
self.comment = comment
self.comment_count = int(comment_count)
self.user = str(user)
self.user_count = int(user_count)
self.following = following
self.liking = liking
self.commenting = commenting
def run(self):
session = InstaPy(username=f"{self.username}", password=f"{self.password}", headless_browser=self.browser)
telegram = InstaPyTelegramBot(token='',
telegram_username='',
instapy_session=session)
session.login()
session.set_user_interact(amount=self.amount, randomize=True, percentage=self.media_per, media='Photo')
session.set_do_follow(enabled=self.following, percentage=self.follow)
session.set_do_like(enabled=self.liking, percentage=self.like)
session.set_comments([self.comment])
session.set_do_comment(enabled=self.commenting, percentage=self.comment_count)
session.interact_user_followers([f"{self.user}"], amount=self.user_count, randomize=True)
session.end()
сейчас кнопка стоп делает terminate(). а как через кнопку стоп заввершить функцию передачей session.end()