Python对常规函数的异步调用

2024-10-02 02:40:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试运行异步函数,该函数将调用常规函数

我试过这个:

import asyncio
from okta.client import Client as OktaClient


def startFunc(metadataURL,appID):
  print("This is the",metadataURL, appID)


config = {
'orgUrl': 'https://example.com',
'token': 'myToken'}

okta_client = OktaClient(config)
async def skipFunc():
 apps, resp, err = await okta_client.list_applications()

 for app in apps:
   appsList = (app.label,app.id)
   for app.label in appsList:
     if app.label == 'John':
       strApp = str(app)
       appJson = ast.literal_eval(strApp)
       metadataURL = (appJson['links']['metadata']['href'])
       appID = (appJson['id'])
       startFunc(metadataURL,appID) ## Trying to call this function

loop = asyncio.get_event_loop()
loop.run_until_complete(skipFunc())

我没有收到输出,看起来函数startFunc()没有执行,我没有收到任何错误

希望你能帮助我


Tags: 函数importclientloopasyncioconfigappdef

热门问题