Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
一旦我收到来自客户端的消息,我不想立即回复,我想等待几秒钟(随机秒数)。我该怎么做?(我使用 Channel API,所以这样的延迟对客户端来说应该没问题)
你可以让线程休眠一段时间:
import thread ... thread.sleep(some_number_of_milliseconds)
对于 App Engine,延迟的内置库的性能比睡眠更好,并且比任务队列更容易设置。
[https://cloud.google.com/appengine/articles/deferred][1]