Another test
This commit is contained in:
@@ -17,6 +17,9 @@ from facebook_business.api import FacebookAdsApi
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
|
||||
class MetaRateLimiter:
|
||||
"""
|
||||
Rate limiter with exponential backoff for Meta Marketing API.
|
||||
@@ -613,13 +616,21 @@ class MetaRateLimiter:
|
||||
|
||||
# X-Ad-Account-Usage (per account)
|
||||
if stats['ad_account_usage']:
|
||||
output.append("X-Ad-Account-Usage (Per Account):")
|
||||
for account_id, usage in stats['ad_account_usage'].items():
|
||||
output.append(f" Account: {account_id}")
|
||||
output.append(f" Usage: {usage.get('acc_id_util_pct', 0):.1f}%")
|
||||
output.append(f" Reset Time: {usage.get('reset_time_duration', 0)}s")
|
||||
output.append(f" API Access Tier: {usage.get('ads_api_access_tier') or 'N/A'}")
|
||||
output.append("")
|
||||
# Only show accounts with data (skip "unknown" accounts with 0 usage)
|
||||
accounts_to_show = {
|
||||
account_id: usage
|
||||
for account_id, usage in stats['ad_account_usage'].items()
|
||||
if account_id != 'unknown' or usage.get('acc_id_util_pct', 0) > 0
|
||||
}
|
||||
|
||||
if accounts_to_show:
|
||||
output.append("X-Ad-Account-Usage (Per Account):")
|
||||
for account_id, usage in accounts_to_show.items():
|
||||
output.append(f" Account: {account_id}")
|
||||
output.append(f" Usage: {usage.get('acc_id_util_pct', 0):.1f}%")
|
||||
output.append(f" Reset Time: {usage.get('reset_time_duration', 0)}s")
|
||||
output.append(f" API Access Tier: {usage.get('ads_api_access_tier') or 'N/A'}")
|
||||
output.append("")
|
||||
|
||||
# X-Business-Use-Case-Usage
|
||||
if stats['buc_usage']:
|
||||
|
||||
@@ -151,7 +151,14 @@ async def test_rate_limiter():
|
||||
print(f"Max usage: {limiter.get_max_usage_pct():.1f}%")
|
||||
print(f"Throttle delay: {limiter.get_throttle_delay():.1f}s")
|
||||
print(f"Estimated time to regain access: {limiter.estimated_time_to_regain_access} min")
|
||||
print(f"Reset time duration: {limiter.reset_time_duration}s")
|
||||
|
||||
# Show per-account reset times
|
||||
if limiter.ad_account_usage:
|
||||
print("Per-account reset times:")
|
||||
for account_id, usage in limiter.ad_account_usage.items():
|
||||
reset_time = usage.get('reset_time_duration', 0)
|
||||
if reset_time > 0:
|
||||
print(f" {account_id}: {reset_time}s")
|
||||
|
||||
# Test 7: Empty/missing headers
|
||||
print("\n--- Test 7: Missing Headers ---")
|
||||
|
||||
Reference in New Issue
Block a user