0

我正在创建一个桌面应用程序,该应用程序在本地执行某些操作之前需要远程服务器的授权。

在服务器批准授权请求时通知我的桌面应用程序的最佳方式是什么?授权平均需要 20 秒,最少 5 秒,超时时间为 120 秒。

我考虑过每隔几秒钟左右轮询一次服务器3,但是当我更广泛地部署应用程序时,这将很难扩展,而且看起来不优雅。

我可以完全控制服务器和客户端 API 的设计。该服务器web.py在 Ubuntu 10.10、Python 2.6 上使用。

4

2 回答 2

0

Does the remote end block while it does the authentication? If so, you can use a simple select to block till it returns.

Another way I can think of is to pass a callback URL to the authentication server asking it to call it when it's done so that your client app can proceed. Something like a webhook.

于 2010-10-20T14:25:13.497 回答
0

你需要做一些异步的事情。我一直是twisted的忠实粉丝,它是一个在 python 中进行异步网络的框架。它支持许多常见的协议,并拥有自己的管道。如果 twisted 看起来有点矫枉过正,您可以在此处比较其他异步框架

于 2010-10-20T17:42:20.833 回答