Community Record
46
Posts
5
Kudos
3
Solutions
Badges
2 weeks ago
Hello, one question here. I see that you use sleep, but how do you retry the endpoint after ?
... View more
Feb 12 2025
4:56 AM
I can't enter the except block, when i ecnonter 429, meraki aio returns it as a warning, so it's not being raised
... View more
Feb 10 2025
1:57 AM
There is one thing i don't understand. How do you use try/except to detect a 429 ? Because the AsyncRestSession code for 429 is this: elif status == 429: wait = 0 if "Retry-After" in response.headers: wait = int(response.headers["Retry-After"]) else: wait = random.randint(1, self._nginx_429_retry_wait_time) if self._logger: self._logger.warning( f"{tag}, {operation} > {abs_url} - {status} {reason}, retrying in {wait} seconds" ) await asyncio.sleep(wait) So it is not raising any exception, therefore you can't catch it in your functions.
... View more
Feb 6 2025
3:56 AM
Thank you @sungod. Can you show me an example of o the wait/retry mechanism ?
... View more
Feb 6 2025
2:07 AM
Looking at logs, I see more than 5 calls pers second, I can't see where the issue is hiding
... View more
Feb 6 2025
12:48 AM
async with meraki.aio.AsyncDashboardAPI( api_key='xyz', base_url='https://api.meraki.com/api/v1', output_log=False, print_console=True, suppress_logging=True, wait_on_rate_limit=True, maximum_retries=100, maximum_concurrent_requests=5 ) as aiomeraki: org_vlan_tasks = [asyncio.create_task(process_organization_vlans(aiomeraki,org,vlan_std_keys,severities)) for org in organizations] await asyncio.gather(*org_vlan_tasks) for network in organization['networks']: tasks.append(asyncio.create_task((process_organization_vlans(aiomeraki,network,vlan_std_keys,organization,severities)))) The smallest function in the chain, uses the initialized meraki.aio dashboard to get vlans. I get multiple 429 errors, and i don't understand why, because i used maximum_concurent_requests at half the threshold, and I am the only one doing api calls on this organization
... View more
Feb 5 2025
11:34 AM
2 Kudos
I had absolutely no idea about ._session._concurrent_requests_semaphore. So this by default submits 10 calls? Where you found it? Thanks
... View more
Feb 5 2025
8:58 AM
I don't see any kind of semaphore in your script. Using asyncio.as_completed should start all of them at once, so if your organization has 30 networks you start 30 workers and hit the rate limit. Am I wrong with this logic?
... View more
Feb 5 2025
7:55 AM
1 Kudo
Thanks for the input, that's how i'm already checking the numer of calls by status code. All are provided by my script thst generates an output of aprox. 500 calls(200+429) for an organization with 120 networks, so the number of calls should be 120. My guess it's that meraki's library parameter wait_on_rate_limit and maximum_retries are causing many duplicates that are unnecessary. May the problem be that i initialize the meraki.aio for every call and it is unaware that it has other instances that are already doing the same thing
... View more
Feb 5 2025
1:56 AM
async def getNetworkAppliancevlansMeraki(self,id😞 async with self.semaphore: try: async with meraki.aio.AsyncDashboardAPI(self.api_key,self.base_url,output_log=False,print_console=True,suppress_logging=True,wait_on_rate_limit=True,maximum_retries=10) as aiomeraki: vlans = await aiomeraki.appliance.getNetworkApplianceVlans(id) return vlans except meraki.AsyncAPIError as e: if e.status == 429: retry_after = int(e.response_headers.get('Retry-After', 1)) log.info(f"Rate limit exceeded. Retrying after {retry_after} seconds.") await asyncio.sleep(retry_after) else: vlans= [] log.info(f"Couldn't get Vlans , error: {e}") return vlans Even if i see hundreds of 429 calls, nothing raises my exception
... View more
Feb 5 2025
1:33 AM
I am using the meraki library, with an semaphore of 10 conccurent workers on top. Even so, when i check the number of calls, the 429 are hundreds. I don't know how to stop it. Once it start getting them, it seems it's never stopping
... View more
Oct 4 2024
2:23 AM
You are right, adapting from javascript to python is pretty easy. I think it would be beneficial to use the library for api calls instead of regular http calls in javascript where we would lack all the parameters the library offers
... View more
Oct 4 2024
1:13 AM
Hello, me and my team will start working on an application that will require concurrent api calls. Until now , i was doing this in python, using the meraki library with it's async package. Now it's discussed if we could do this using javascript, as the rest of the programmers are not familiar with python. Is there any meraki package for node, and if yes, is it as good as the python one ?
... View more
Mar 29 2024
3:17 AM
2 Kudos
Everything seems fine, action batches gave me a hard time and I stopped trying to use them. Instead I work with meraki.aio library and make concurrent calls for efficiency
... View more
Mar 29 2024
2:53 AM
Hello guys, i tried a workaround today with this call this call should return that profile parameter which shows the id of the switch profile. The problem is that running this call in postman/ script , with the latest api, is not returning that profile attribute, even if the switch is 100% assigned to a switch profile. Am I doing something wrong ? Is there other way to list the association between switches and switch profiles ? Thanks
... View more
Mar 28 2024
3:06 AM
It's not about an easier solution. It's about automating a manual task, where network engineers have to manually create switch profiles from the dashboard. Or do you have another way to solve my problem ?
... View more
Mar 27 2024
3:19 AM
hopefully next api versions will implement it
... View more
Mar 27 2024
2:07 AM
Hello, I am facing a task that needs to copy some switch profiles from a config template to an other one. Unfortunately, I see no support for creating/cloning switch profiles using the API. I am missing something ? All i see is an update option of the profile ports, put only after the profile already exists
... View more
Mar 23 2023
6:33 AM
Hello everybody. I found the solution to my problem. I used asyncio Semaphore to limit on the number of threads. sem=asyncio.Semaphore(10) network_template_tasks = [asyncio.ensure_future(append_template(net, org_id,sem)) for net in networks]. Now the script is not getting the 429 error.
... View more
Mar 22 2023
2:12 AM
Thank you sungod for your multiple answers to the topic. Unfortunately i have the same problem even with a simple python script. For me it makes sense. Concurrent calls go above 10 request per second, which is the limit from Meraki. I can't identify any mistake in my script that would do that
... View more
Mar 22 2023
2:10 AM
This is the problem. I want to postpone the automatic updates that meraki schedules. But I can't do that without affecting the updates scheduled by administrators. Thanks
... View more
Mar 21 2023
8:10 AM
and the loading of the page is infinite. So it is stuck somewhere the api request
... View more
Mar 21 2023
8:09 AM
The behavior is the same. what i observed is that i no longer get the error " 429 too many request" , but , there still are to many requests because if i make a random call on that specific organization in postman i get that there are to many api calls. So idk what to do anymore honestly
... View more
Mar 21 2023
8:00 AM
This is the script if it helps you more async def get_organizations():
async with meraki.aio.AsyncDashboardAPI(
api_key,
base_url="https://api.meraki.com/api/v1",
output_log = False,
print_console = False,
suppress_logging=True,
wait_on_rate_limit=True, ##### do wait if rate limited
maximum_retries=100 ##### set the retry limit
) as aiomeraki:
organizations= await aiomeraki.organizations.getOrganizations()
return organizations
#################################################################################### FUNCTIONS ####################################
async def get_template_name(org_id,config_template_id):
async with meraki.aio.AsyncDashboardAPI(
api_key,
base_url="https://api.meraki.com/api/v1",
output_log = False,
print_console = False,
suppress_logging=True,
wait_on_rate_limit=True, ##### do wait if rate limited
maximum_retries=100 ##### set the retry limit
) as aiomeraki:
template=await aiomeraki.organizations.getOrganizationConfigTemplate(
org_id, config_template_id
)
template_name=template['name']
return template_name
async def append_template(network,org_id):
template_list=[]
if network['isBoundToConfigTemplate']==True:
template_name= await get_template_name(org_id,network['configTemplateId'])
template= {"id" :network['configTemplateId'], "name" :"Template - "+ template_name }
if template not in template_list:
template_list.append(template)
elif network['isBoundToConfigTemplate']==False:
network={"id":network['id'],"name":"Network - " +network['name']}
if network not in template_list:
template_list.append(network)
await asyncio.sleep(2)
return template_list
#################################################################################### ROUTES #######################################
@app.route('/favicon.ico')
async def favicon():
return "Da"
@app.route("/")
async def render_organizations():
organizations=await get_organizations()
return render_template("organizations.html",organizations=organizations)
@app.route('/<org_id>')
async def organization_detail(org_id):
organization_id = org_id
async with meraki.aio.AsyncDashboardAPI(
api_key,
base_url="https://api.meraki.com/api/v1",
output_log=False,
print_console=False,
suppress_logging=True,
wait_on_rate_limit=True, ##### do wait if rate limited
maximum_retries=100 ##### set the retry limit
) as aiomeraki:
try:
networks = await aiomeraki.organizations.getOrganizationNetworks(
organization_id, total_pages="all"
)
except OSError as e:
print(e)
template_list = []
# create a list of all network template tasks
network_template_tasks = [append_template(net, org_id) for net in networks]
# iterate over the completed tasks as they finish
for coro in asyncio.as_completed(network_template_tasks):
# await asyncio.sleep(2)
template_list.extend(await coro)
return render_template("templates.html", templates=template_list)
... View more
Kudos given to
My Accepted Solutions
Subject | Views | Posted |
---|---|---|
8073 | Mar 23 2023 6:33 AM | |
1872 | Mar 2 2023 5:15 AM | |
1310 | Mar 2 2023 12:35 AM |
My Top Kudoed Posts
Subject | Kudos | Views |
---|---|---|
2 | 1566 | |
2 | 1425 | |
1 | 1664 |