Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python中,回调函数从不使用多处理调用_Python_Python 3.x_Multiprocessing_Pool - Fatal编程技术网

在python中,回调函数从不使用多处理调用

在python中,回调函数从不使用多处理调用,python,python-3.x,multiprocessing,pool,Python,Python 3.x,Multiprocessing,Pool,我正在尝试对processus进行多处理,但我很难理解为什么我的工作人员不应用函数get\u data methods = ["followers", "friends"] for author in authors: pool = multiprocessing.Pool(2) is_present = session.execute("SELECT * FROM {0} WHERE node_id={1}".format("network", author.twitter_

我正在尝试对processus进行多处理,但我很难理解为什么我的工作人员不应用函数
get\u data

methods = ["followers", "friends"]

for author in authors:
    pool = multiprocessing.Pool(2)
    is_present = session.execute("SELECT * FROM {0} WHERE node_id={1}".format("network", author.twitter_id))
    if not is_present:
        for method in methods:
            print(author.twitter_username)
            pool.apply_async(get_data, args=(method, author, session))
        pool.close()
        pool.join()
    else:
        print(author.twitter_username, "Already present in the database ")
函数get data只是一个print():

当我运行我的程序时,我得到: 所有作者的列表显示两次,但不打印
get\u data


那些工人有什么问题?为什么他们没有正确调用get_data?

您是如何运行此程序的?您是否使用像IDLE这样的IDE?通常,他们会有一个“假”标准输出,它会发送到他们的模拟终端,但子进程不会知道这一点,您也无法看到它们的输出。我使用pycharm,但我不认为问题来自IDE,我只是重新格式化了函数get_data,它以前工作过
def get_data(tweepy_function, author, session):
    print(tweepy_function, authot.twitter_id, session)