Skip to content

Commit

Permalink
#1 remove asyncio
Browse files Browse the repository at this point in the history
  • Loading branch information
Scobiform committed Apr 17, 2024
1 parent 20886c6 commit c1574b4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions start.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncio
import logging
import os
import subprocess
Expand Down Expand Up @@ -40,18 +39,19 @@ async def fetch_all_items(user, method):
max_id = None

while True:
loop = asyncio.get_event_loop()
# Run the synchronous method in an executor to prevent blocking
response = await loop.run_in_executor(None, method, user['id'], 500, max_id)
if not response:
break
response = method(user['id'], limit=500, max_id=max_id)
items.extend(response)
if len(response) < 500:
break
max_id = response[-1]['id']

logging.info(f"Final Max ID: {max_id}")
logging.info(f"Total Items Fetched: {len(items)}")
# Logging
logging.info(f"Method: {method}")
logging.info(f"User: {user}")
logging.info(f"Max ID: {max_id}")
logging.info(f"Response: {response}")
logging.info(f"Response length: {len(response)}")
logging.info(f"Items length: {len(items)}")

return items

Expand Down

0 comments on commit c1574b4

Please sign in to comment.