K
K
killeryStark2020-09-17 12:45:15
Python
killeryStark, 2020-09-17 12:45:15

How to terminate QThread thread via signal?

i have a stream

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()


now the stop button does terminate(). and how to end the function through the stop button by passing session.end ()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question