CoolFace
Apppublic

honeybansal23/nextAnalytics

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
test.py45 linesDownload Raw Back to root
1# import asyncio2# import traceback3# from reddit.scraping import getPostComments4# from reddit.load_env import reddit_clients5 6# async def test(fileNames):7#     try:8#         await getPostComments(file_name=fileNames[0])9#         # Semaphore to limit concurrent tasks10#         # semaphore = asyncio.Semaphore(1)11 12#         # # Async function to call getPostComments with semaphore13#         # async def fetch_comments_with_limit(file_name, index):14#         #     async with semaphore:15#         #         await getPostComments(file_name=file_name, is_for_competitor_analysis=True, index=index%len(reddit_clients))16 17#         # # Chunk the fileNames list into batches of 318#         # batches = [fileNames[i:i + 3] for i in range(0, len(fileNames), 3)]19 20#         # # Process each batch with a 5-second wait after completion21#         # for batch_index, batch in enumerate(batches):22#         #     print(f"Processing batch {batch_index + 1} with files: {batch}")23#         #     await asyncio.gather(24#         #         *[fetch_comments_with_limit(file_name=batch[i], index=i + 1) for i in range(len(batch))]25#         #     )26 27#         return {'details': 'Success'}28#     except Exception as e:29#         traceback.print_exc()30#         return {'details': str(e)}31 32 33# file_names = [34#     "posts_data_1735840629809373.csv",35#     "posts_data_1735840629809374.csv",36#     "posts_data_1735840629809375.csv",37#     "posts_data_1735842064975643.csv",38# ]39 40# async def main():41#     result = await test(file_names)42#     print(result)43 44# asyncio.run(main())45