Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
migrate_video_to_qiniu.py
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