diff --git a/src/drstats/__init__.py b/src/drstats/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/drstats/__main__.py b/src/drstats/__main__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/drstats/__pycache__/__init__.cpython-312.pyc b/src/drstats/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index ae4e685..0000000 Binary files a/src/drstats/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/src/drstats/__pycache__/db.cpython-312.pyc b/src/drstats/__pycache__/db.cpython-312.pyc deleted file mode 100644 index 37425a7..0000000 Binary files a/src/drstats/__pycache__/db.cpython-312.pyc and /dev/null differ diff --git a/src/drstats/__pycache__/devrant.cpython-312.pyc b/src/drstats/__pycache__/devrant.cpython-312.pyc deleted file mode 100644 index f0685fd..0000000 Binary files a/src/drstats/__pycache__/devrant.cpython-312.pyc and /dev/null differ diff --git a/src/drstats/__pycache__/statistics.cpython-312.pyc b/src/drstats/__pycache__/statistics.cpython-312.pyc deleted file mode 100644 index f37f9ea..0000000 Binary files a/src/drstats/__pycache__/statistics.cpython-312.pyc and /dev/null differ diff --git a/src/drstats/__pycache__/sync.cpython-312.pyc b/src/drstats/__pycache__/sync.cpython-312.pyc deleted file mode 100644 index 5a88694..0000000 Binary files a/src/drstats/__pycache__/sync.cpython-312.pyc and /dev/null differ diff --git a/src/drstats/sync.py b/src/drstats/sync.py index bdc74f7..7145bde 100644 --- a/src/drstats/sync.py +++ b/src/drstats/sync.py @@ -40,21 +40,29 @@ async def get_recent_rants(start_from=1, page_size=10): start_from += page_size +async def _sync_rants(start_from, page_size,count): + async for rant in get_recent_rants(start_from, page_size): + start_from += page_size + count += 1 + rant["tags"] = json.dumps(rant["tags"]) + db["rants"].upsert(rant, ["id"]) + print(f"Upserted {count} rant(s).") + return count + async def sync_rants(): count = 0 start_from = 0 page_size = 20 - try: - async for rant in get_recent_rants(start_from, page_size): + while True: + try: + count += await asyncio.wait_for(_sync_rants(start_from, page_size,count),5) start_from += page_size - count += 1 - rant["tags"] = json.dumps(rant["tags"]) - db["rants"].upsert(rant, ["id"]) - print(f"Upserted {count} rant(s).") - except: - print("Rate limit of server exceeded. That's normal.s") + except Exception as ex: + print(ex) + print("If exception described above is an timeout related error, it's due ratelimiting and considered OK.") + break async def sync_comments():