Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Tips / async await

async await

JavaScript 早期用 callback 再用 promise 最新有 asynchronous function 來處理非同步,基本 async await 很單純,但在 loop 裡就會變得複雜。

如何應用於實務

2019/01/15 Thinker: Promise 是垃圾: JavaScript Promise 等同於 Python async/await 但設計上脫離 Pythonic
問: await coro() 而 coro() call 了 blocking function 叫 foo() 被執行到什麼程度才被抽掉? 答: 除非 coro() 裡有 await 不然不會轉讓執行權 "給別人做"這件事, 還是要自己開 thread 或是接 tornado 之類

thread synchronization