ohld / igbot

🐙 Free scripts, bots and Python API wrapper. Get free followers with our auto like, auto follow and other scripts!
https://hikerapi.com/p/N2P6iqiM
Apache License 2.0
4.72k stars 1.47k forks source link

ValueError: signal only works in main thread #641

Closed md4956 closed 5 years ago

md4956 commented 6 years ago

Code:

def follow_hashtag_commenters(username, password, hashtags):
    parser = argparse.ArgumentParser(add_help=True)
    parser.add_argument('-proxy', type=str, help="proxy")
    args = parser.parse_args()

    bot = Bot(max_likes_per_day=35, max_follows_per_day=40, max_comments_per_day=40)
    bot.login(username=username, password=password, proxy=args.proxy)
    user_id = bot.get_user_id_from_username(username)
    .
    .
    .

Error/Debug Log:

Cookie file `cookie.txt` not found
2018-09-11 17:24:08,139 - INFO - Logged-in successfully as 'xxx'!
2018-09-11 17:24:08,140 - INFO - Saved cookie!
127.0.0.1 - - [11/Sep/2018 17:24:08] "GET /follow_hashtag_commenters?username=xxx&password=yyy&hashtags=zzz HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/Users/admin/Desktop/instabot-venv/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/admin/Desktop/instabot-venv/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app
    response = self.handle_exception(e)
  File "/Users/admin/Desktop/instabot-venv/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/admin/Desktop/instabot-venv/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/Users/admin/Desktop/instabot-venv/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/admin/Desktop/instabot-venv/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/admin/Desktop/instabot-venv/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/admin/Desktop/instabot-venv/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/Users/admin/Desktop/instabot-venv/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/admin/Desktop/instabot-venv/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/admin/Desktop/first_app/py/main.py", line 14, in fhc
    instaapp.follow_hashtag_commenters(username, password, hashtags)
  File "/Users/admin/Desktop/first_app/py/instaapp.py", line 19, in follow_hashtag_commenters
    bot.login(username=username, password=password, proxy=args.proxy)
  File "/Users/admin/Desktop/instabot-venv/lib/python3.6/site-packages/instabot/bot/bot.py", line 237, in login
    signal.signal(signal.SIGTERM, self.logout)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/signal.py", line 47, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread

If I enter a correct username and password (I tried 4 personal account), this will happen. If I put wrong credential, it works normally. Before today, everything was fine. now, I am facing with this error without make any changes in my code.

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

ghyath5 commented 4 years ago

Hey @md4956 I am facing same issue. Have you resolve this problem ?

md4956 commented 4 years ago

Hi @ghyath5

With this repository's solutions, no. I've fixed it by creating a multi-thread process, using another library.

bogtan commented 4 years ago

You can pass is_threaded=True to bot.login() to avoid this issue.

From bot.login():

        if "is_threaded" in args:
            if args["is_threaded"]:
                return True
        signal.signal(signal.SIGTERM, self.print_counters)