多处理池未执行功能

时间:2019-07-10 14:39:09

标签: python python-3.x multiprocessing python-multiprocessing pool

过去5个小时我一直在处理此问题,但我不知道自己在做什么错。它仅显示“ Running pool ...”,但似乎未执行该功能。它不会抛出任何错误,而是会继续运行。

conn = pymysql.connect(host, user=user,port=port,passwd=password, db=dbname)

SQL = 'SELECT * FROM Clean_SBIR LIMIT {}, 20000'

def process_data(offset):
    print('Offset original: ',offset)
    offset = offset * 20000
    print('Actual offset: ',offset)
    df = pd.read_sql((SQL).format(offset), conn)
    print(offset)
    return len(df)

if __name__ == "__main__":
    with Pool(4) as pool:
        print('Running pool...')

        result = pool.apply_async(process_data, [1,2,3])
        print(result.get())
        print(pool.map(process_data, [1,2,3]))

0 个答案:

没有答案