Created
September 13, 2018 13:21
-
-
Save wwj718/0b58173f20f002a0d4d70f2fa839781e to your computer and use it in GitHub Desktop.
migrate_video_to_qiniu.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import aiohttp | |
import asyncio | |
import time | |
df = pd.read_csv('qiniu_url.csv') | |
async def job(session, url): | |
response = await session.options(url) | |
if response.status == 200: | |
print("ok") | |
# print(f"bad_url:{url}") | |
async def main(loop): | |
async with aiohttp.ClientSession() as session: | |
tasks = [loop.create_task(job(session, url)) for url in df['qiniu_url'] if "mp4" in url.lower()] | |
finished, unfinished = await asyncio.wait(tasks) | |
all_results = [r.result() for r in finished] | |
print(len(all_results)) | |
t1 = time.time() | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(main(loop)) | |
loop.close() | |
print("Async total time:", time.time() - t1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment