如何使用Threading获取AssertionError来调用没有参数的方法

时间:2016-07-24 15:57:37

标签: python multithreading

所以我有一些编译和处理主线程的方法,但是我想在将来成功运行后的某个时间运行一组方法。我研究了导入线程,时间和日期时间类。 Thread()中的next_call_auto变量是一个等待约3小时秒的整数。

问题是线程何时启动。我从 init 到达一个AssertionError,说“组参数必须暂时注意”。程序编译,但不执行下面此方法中的最后一行,并返回下面的堆栈跟踪。

                $.getJSON(uri + search)
                    .done(function (data) {
                        data = data[0];
                        $('#mountain').text(formatItem(data));
                    })

1 个答案:

答案 0 :(得分:0)

根据current docs,这个电话:

Thread(group = next_call_auto, target = auto_follow_others_thread)

与:

相同
group

因为next_call_auto是构造函数的第一个位置参数。但是,正如错误消息所提到的那样,组未实现 唯一有效的值是None。

另外,你的意思是“next_call_auto 是一个等待约3小时秒的整数”?你的意思是auto_follow_others_thread是3 * 3600吗?

如果您想在一段时间后启动time.sleep()的正文,只需在def auto_follow_others_thread( delay ): time.sleep(delay) auto_fav("socialmediamarketing", count=randint(0,1)) ... 处拨打电话即可 例程的开始:

Thread(target=auto_follow_others_thread, args=(3*3600,)).start()

然后用:

启动线程
with open('file.txt', 'r') as f:
    i = 0
    for fline in f:
        process(fline)
        i = i + 1
print i