Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support async request sdk #81

Open
wangxin688 opened this issue Mar 2, 2023 · 6 comments
Open

support async request sdk #81

wangxin688 opened this issue Mar 2, 2023 · 6 comments
Assignees

Comments

@wangxin688
Copy link

now python sdk is only support sync way, is there any plan to add async with httpx or aiohttp client?
or I don't not if you will aceept PR/MR for community?

@jbogarin
Copy link
Collaborator

jbogarin commented Mar 2, 2023

@wangxin688 I'm assigning this to @zapodeanu as the Cisco lead.

@zapodeanu
Copy link
Collaborator

@wangxin688 This is an interesting ask. We need to investigate this, to see the implications on the Cisco DNA Center Platform.

@dannysheridan
Copy link

dannysheridan commented Mar 26, 2023

@zapodeanu if you're open to auto-generating the Python SDK, you can get async out-of-the-box. www.buildwithfern.com

@zapodeanu
Copy link
Collaborator

zapodeanu commented Mar 30, 2023

@wangxin688 This is an interesting ask. We need to investigate this, to see the implications on the Cisco DNA Center Platform.
@wangxin688
At this time there is no support for httpx or aiohttp clients. I am not sure how many workflow automations would have a real performance improvement from them.

@wangxin688
Copy link
Author

@wangxin688 This is an interesting ask. We need to investigate this, to see the implications on the Cisco DNA Center Platform.
@wangxin688
At this time there is no support for httpx or aiohttp clients. I am not sure how many workflow automations would have a real performance improvement from them.

thanks. hope to receive your feedback asap

@legion49f
Copy link
Contributor

why cant you use a thread pool executor? it is safe to use with the requests pkg

import concurrent.futures
from typing import List, Mapping
from dnacentersdk import api

client = api.DNACenterAPI(
    username="username",
    password="password",
    base_url="url",
    version="2.3.3.0",
    verify=False,
    single_request_timeout=60,
)
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
    device_uuids = ["wefwewefwef", "efw", "fwefwwefweefw", "fwefwefwefwfwef"]
    futures = []
    results: List[Mapping] = list()
    for uuid in device_uuids:
        futures.append(
            executor.submit(
                client.devices.get_device_by_id,
                id=uuid,
            )
        )
    for future in concurrent.futures.as_completed(futures):
        results.append(future.result())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants