什麼是 RabbitMQ?
RabbitMQ 是 message broker (消息代理) 軟體
當中傳輸消息的協定是使用 AMQP (Advanced Message Queuing Protocol,高級消息隊列協議)
當中傳輸消息的協定是使用 AMQP (Advanced Message Queuing Protocol,高級消息隊列協議)
concurrent.futures module提供python異步執行的高階interface
https://docs.python.org/3/library/concurrent.futures.html
這裡介紹當中的 ThreadPoolExecutor,當你有一個工作可以切分成多塊重複執行時,可以透過使用 ThreadPoolExecutor 建立多個 thread 併發跑。
透過創建 threading.local() 我們可以建立 thread 的 local storage
local 物件為 thread-specific,每個 thread 的值各自獨立,不會互影響
上章學會了 Python Thread 的基本寫法
這章要講的是當你的程式用到 multi-thread ,有個一定要小心的問題,那就是:Race Condition