简体   繁体   English

我应该为每个请求阅读googleads.yaml文件吗?

[英]Should I read googleads.yaml file for every request?

I've been testing Python Google AdWords Library and every example does authentication the same way, reading the googleads.yaml (taking 15-20 seconds) which is horribly slow. 我一直在测试Python Google AdWords库 ,每个示例都以相同的方式进行身份验证,读取googleads.yaml(耗时15-20秒),这非常慢。 I read that there's a caching alternative but I still don't understand how to do it. 我读到有一个缓存替代方法,但我仍然不知道该怎么做。 How can I create a client, initialize it at the start of the application, only once? 如何创建一个客户端,仅在应用程序启动时对其进行一次初始化?

Once you have initialized your adwords.AdWordsClient instance using the LoadFromStorage() constructor, you can keep it for however long you want. 使用LoadFromStorage()构造函数初始化adwords.AdWordsClient实例后,您可以将其保留任意长时间。 It will refresh the provided access token on its own when required. 需要时,它将自行刷新提供的访问令牌。

Having said that, reading the yaml file and obtaining the initial access token should take nowhere near 15 seconds. 话虽如此,但读取yaml文件并获取初始访问令牌应该只需15秒。 Are you sure the code is not blocking elsewhere? 您确定代码不会在其他地方阻塞吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM