线程加载程序

时间:2019-07-06 16:55:30

标签: python-multithreading loader

当查询从在线资源下载数据时,我正在尝试实现一些线程:

from random import random
import threading
import time

from astroquery.utils.tap.core import Tap

download_finished = threading.Event()

def background_download():
    gaiaURL = "http://gea.esac.esa.int/tap-server/tap"

    query2 = "SELECT * FROM gaiadr2.gaia_source AS gaia WHERE gaia.frame_rotator_object_type = 2"

    gaia = Tap(url=gaiaURL)

    job2 = gaia.launch_job_async(query2, name=None, output_file="type2.vot",
                         output_format="votable", verbose=False,
                         dump_to_file=True, background=False,
                         upload_resource=None, upload_table_name=None)

    download_finished.set()

def main():
    thread = threading.Thread(target=background_download)
    thread.start()

    download_finished.wait()

    print('Download Complete')

if __name__ == '__main__':
    main()

我有两个问题

  1. 这是执行线程化的正确方法吗?

更重要的是

  1. 如何放置一个简单的装载器,例如在查询过程中每秒打印句号(“。”)?

0 个答案:

没有答案