-1

So I have some methods that compile and work on the main thread, but I wanted to run a collection of methods at a certain time in the future after they successful run. I looked into importing the threading, time, and datetime classes. The next_call_auto variable in Thread() is an integer that waits for ~3 hours worth of seconds.

The problem is when the Thread gets started. I reach an AssertionError that says "group argument must be Note for now" from init. The program compiles, but doesn't execute the last line in this method below and returns the stack trace below.

def auto_follow_others_thread():
    auto_fav("socialmediamarketing", count=randint(0,1))
    auto_follow("socialmediamarketing", count=randintWithHalfRandomness())
    auto_fav("softwaredevelopment", count=randint(0,1))
    auto_follow("softwaredevelopment", count=randintWithHalfRandomness())
    auto_fav("startup", count=randint(0,1))
    auto_follow("startup", count=randintWithHalfRandomness())
    auto_fav("smm", count=randint(0,1))
    auto_follow("smm", count=randintWithHalfRandomness())
    auto_fav("homebrew", count=randint(0,1))
    auto_follow("homebrew", count=randintWithHalfRandomness())
    auto_fav("nomad", count=randint(0,1))
    auto_follow("nomad", count=randintWithHalfRandomness())
    threading.Thread(next_call_auto, target=auto_follow_others_thread).start()


Traceback (most recent call last):
  File "sample_twitter_codes.py", line 73, in <module>
auto_follow_others_thread()
  File "C:\Users\Rick\Desktop\TwitterFolloers\grow-twitter-following-master\twitter_follow_bot.py", line 87, in auto_follow_others_thread
auto_fav("socialmediamarketing", count=randint(0,1))
  File "C:\Users\Rick\Desktop\TwitterFolloers\grow-twitter-following-master\twitter_follow_bot.py", line 84, in auto_fav
threading.Thread(next_call_fav, target=auto_fav, args=()).start()
  File     "C:\Users\Rick\AppData\Local\Programs\Python\Python35\lib\threading.py",
line 778, in __init__
assert group is None, "group argument must be None for now"
AssertionError: group argument must be None for now
Jayizzle
  • 532
  • 1
  • 6
  • 24
  • 2
    Possible duplicate of [AssertionError when threading in Python](http://stackoverflow.com/questions/15349997/assertionerror-when-threading-in-python) –  Jul 24 '16 at 20:01
  • I have seen that, that uses one parameter while mine doesn't. ITs taken care of now, so thank you. – Jayizzle Jul 25 '16 at 18:17

1 Answers1

0

According to the docs for the Threading class, this call:

Thread(next_call_auto, target=auto_follow_others_thread)

is the same as:

Thread(group = next_call_auto, target = auto_follow_others_thread)

because group is the first positional argument for the constructor. However, as the error message mentions, groups are not implemented so the only valid value is None.

Also, what exactly you do you mean by "next_call_auto is an integer that waits for ~3 hours worth of seconds" ? Do you mean next_call_auto is 3*3600 ?

If you want to start the body of auto_follow_others_thread after a certain amount of time, just insert a call to time.sleep() at the beginning of the routine:

def auto_follow_others_thread( delay ):
    time.sleep(delay)
    auto_fav("socialmediamarketing", count=randint(0,1))
    ...

Then start the thread with:

Thread(target=auto_follow_others_thread, args=(3*3600,)).start()
ErikR
  • 51,541
  • 9
  • 73
  • 124