remove static rate limit delay

This commit is contained in:
rambros 2026-03-08 02:27:04 +05:30
parent 104a284f88
commit 3b3b262d8b
10 changed files with 13 additions and 32 deletions

View file

@ -5,7 +5,6 @@ from pydantic import BaseModel, Field
class MigrationSettings(BaseModel): class MigrationSettings(BaseModel):
batch_size: int = Field(default=100) batch_size: int = Field(default=100)
rate_limit_delay_seconds: int = Field(default=2)
log_level: str = Field(default="DEBUG") log_level: str = Field(default="DEBUG")
class AppConfig(BaseModel): class AppConfig(BaseModel):

View file

@ -115,7 +115,6 @@ async def migrate_channels(context: MigrationContext, progress_callback: Callabl
current_idx += 1 current_idx += 1
if progress_callback: await progress_callback(f"Cat: {cat.name}", "Copying", current_idx, total) if progress_callback: await progress_callback(f"Cat: {cat.name}", "Copying", current_idx, total)
await asyncio.sleep(context.config.migration.rate_limit_delay_seconds)
# Create missing channels # Create missing channels
for channel in channels_to_create: for channel in channels_to_create:
@ -161,7 +160,6 @@ async def migrate_channels(context: MigrationContext, progress_callback: Callabl
current_idx += 1 current_idx += 1
if progress_callback: await progress_callback(channel.name, "Copying", current_idx, total) if progress_callback: await progress_callback(channel.name, "Copying", current_idx, total)
await asyncio.sleep(context.config.migration.rate_limit_delay_seconds)
# Move/Sync existing channels # Move/Sync existing channels
for channel, fluxer_id in channels_to_move: for channel, fluxer_id in channels_to_move:
@ -190,6 +188,5 @@ async def migrate_channels(context: MigrationContext, progress_callback: Callabl
current_idx += 1 current_idx += 1
if progress_callback: await progress_callback(channel.name, "Syncing", current_idx, total) if progress_callback: await progress_callback(channel.name, "Syncing", current_idx, total)
await asyncio.sleep(context.config.migration.rate_limit_delay_seconds)
return cloned_info return cloned_info

View file

@ -113,6 +113,5 @@ async def migrate_emojis(context: MigrationContext, progress_callback: Callable[
logger.error(f"Error downloading/uploading {obj_type.lower()} {obj.name}: {e}") logger.error(f"Error downloading/uploading {obj_type.lower()} {obj.name}: {e}")
if progress_callback: await progress_callback(obj.name, obj_type, idx + 1, total) if progress_callback: await progress_callback(obj.name, obj_type, idx + 1, total)
await asyncio.sleep(context.config.migration.rate_limit_delay_seconds)
return cloned_assets return cloned_assets

View file

@ -299,7 +299,6 @@ async def migrate_messages(
logger.error(traceback.format_exc()) logger.error(traceback.format_exc())
# Delay for rate limit safety # Delay for rate limit safety
await asyncio.sleep(context.config.migration.rate_limit_delay_seconds)
except (KeyboardInterrupt, asyncio.CancelledError): except (KeyboardInterrupt, asyncio.CancelledError):
context.is_running = False context.is_running = False
pass pass

View file

@ -160,6 +160,5 @@ async def migrate_roles(context: MigrationContext, progress_callback: Callable[[
cloned_role_names.append(role.name) cloned_role_names.append(role.name)
if progress_callback: await progress_callback(role.name, idx + 1, total) if progress_callback: await progress_callback(role.name, idx + 1, total)
await asyncio.sleep(context.config.migration.rate_limit_delay_seconds)
return cloned_role_names return cloned_role_names

View file

@ -116,7 +116,6 @@ async def migrate_channels(context: MigrationContext, progress_callback: Callabl
current_idx += 1 current_idx += 1
if progress_callback: await progress_callback(f"Cat: {cat.name}", "Copying", current_idx, total) if progress_callback: await progress_callback(f"Cat: {cat.name}", "Copying", current_idx, total)
await asyncio.sleep(context.config.migration.rate_limit_delay_seconds)
# 2. Create missing channels (unparented for now) # 2. Create missing channels (unparented for now)
for channel in channels_to_create: for channel in channels_to_create:
@ -158,7 +157,6 @@ async def migrate_channels(context: MigrationContext, progress_callback: Callabl
current_idx += 1 current_idx += 1
if progress_callback: await progress_callback(channel.name, "Copying", current_idx, total) if progress_callback: await progress_callback(channel.name, "Copying", current_idx, total)
await asyncio.sleep(context.config.migration.rate_limit_delay_seconds)
# 3. Move/Sync existing channels # 3. Move/Sync existing channels
for channel, target_id in channels_to_move: for channel, target_id in channels_to_move:
@ -183,7 +181,6 @@ async def migrate_channels(context: MigrationContext, progress_callback: Callabl
current_idx += 1 current_idx += 1
if progress_callback: await progress_callback(channel.name, "Syncing", current_idx, total) if progress_callback: await progress_callback(channel.name, "Syncing", current_idx, total)
await asyncio.sleep(context.config.migration.rate_limit_delay_seconds)
# 4. Final step: Parent the channels into categories via mass server.edit() # 4. Final step: Parent the channels into categories via mass server.edit()
logger.info("Parenting all channels into their respective categories...") logger.info("Parenting all channels into their respective categories...")

View file

@ -100,6 +100,5 @@ async def migrate_emojis(context: MigrationContext, progress_callback: Callable[
logger.error(f"Error downloading/uploading {obj_type.lower()} {obj.name}: {e}") logger.error(f"Error downloading/uploading {obj_type.lower()} {obj.name}: {e}")
if progress_callback: await progress_callback(obj.name, obj_type, idx + 1, total) if progress_callback: await progress_callback(obj.name, obj_type, idx + 1, total)
await asyncio.sleep(context.config.migration.rate_limit_delay_seconds)
return cloned_assets return cloned_assets

View file

@ -305,8 +305,6 @@ async def migrate_messages(
import traceback import traceback
logger.error(traceback.format_exc()) logger.error(traceback.format_exc())
# Delay for rate limit safety
await asyncio.sleep(context.config.migration.rate_limit_delay_seconds)
except (KeyboardInterrupt, asyncio.CancelledError): except (KeyboardInterrupt, asyncio.CancelledError):
context.is_running = False context.is_running = False
pass pass

View file

@ -161,7 +161,6 @@ async def sync_permissions(context: MigrationContext, progress_callback: Callabl
current_idx += 1 current_idx += 1
if progress_callback: await progress_callback(channel.name, current_idx, total) if progress_callback: await progress_callback(channel.name, current_idx, total)
await asyncio.sleep(context.config.migration.rate_limit_delay_seconds)
logger.info(f"Stoat permissions sync complete: {len(synced_info['categories_synced'])} categories, {len(synced_info['channels_synced'])} channels.") logger.info(f"Stoat permissions sync complete: {len(synced_info['categories_synced'])} categories, {len(synced_info['channels_synced'])} channels.")
@ -208,7 +207,5 @@ async def migrate_roles(context: MigrationContext, progress_callback: Callable[[
cloned_role_names.append(role.name) cloned_role_names.append(role.name)
if progress_callback: await progress_callback(role.name, idx + 1, total) if progress_callback: await progress_callback(role.name, idx + 1, total)
await asyncio.sleep(context.config.migration.rate_limit_delay_seconds)
return cloned_role_names return cloned_role_names

View file

@ -436,27 +436,24 @@ class ConfigScreen(Screen):
# ── save / start ───────────────────────────────────────────────────── # ── save / start ─────────────────────────────────────────────────────
def _collect_and_save(self) -> None: def _collect_and_save(self) -> None:
token = self.query_one("#inp_discord_token", Input).value.strip() # 1. Discord Section
self.config.discord_bot_token = token or None self.config.discord_bot_token = self.query_one("#inp_discord_token", Input).value.strip() or None
server_select = self.query_one("#inp_discord_server", Select) d_select = self.query_one("#inp_discord_server", Select)
if server_select.value != Select.BLANK: if d_select.value not in (Select.BLANK, Select.NULL):
self.config.discord_server_id = str(server_select.value) self.config.discord_server_id = str(d_select.value)
else:
self.config.discord_server_id = None
# 2. Mode
self.config.tool_mode = self._get_selected_mode() self.config.tool_mode = self._get_selected_mode()
# 3. Target Section
if self.config.tool_mode != "backup_only": if self.config.tool_mode != "backup_only":
self.config.target_platform = self._get_selected_platform() self.config.target_platform = self._get_selected_platform()
target_token = self.query_one("#inp_target_token", Input).value.strip() self.config.target_bot_token = self.query_one("#inp_target_token", Input).value.strip() or None
self.config.target_bot_token = target_token or None
target_select = self.query_one("#inp_target_server", Select) t_select = self.query_one("#inp_target_server", Select)
if target_select.value != Select.BLANK: if t_select.value not in (Select.BLANK, Select.NULL):
self.config.target_server_id = str(target_select.value) self.config.target_server_id = str(t_select.value)
else:
self.config.target_server_id = None
target_api = self.query_one("#inp_target_api", Input).value.strip() target_api = self.query_one("#inp_target_api", Input).value.strip()
self.config.target_api_url = target_api or None self.config.target_api_url = target_api or None