Python Concurrency
发布于
2017-11-07 13:55:05
- 多进程
- fork()
- multiprocessing
- Process
- Pool
- map()
- imap_unordered()
- apply_async()
- close()
- join()
- (Exchange objects)
- Queue
- put()
- get()
- empty()
- full()
- qsize()
- close()
- join_thread()
- cancel_join_thread()
- Queues are thread and process safe.
- doc of methods
- Pipes
- (Synchronization between processes)
- (Sharing state between processes)
- Value, Array
- Manager
- list, dict, Namespace, Lock, RLock, Semaphore, BoundedSemaphore, Condition, Event, Queue, Value and Array
- managers
- (miscellaneous)
- active_children()
- cpu_count()
- current_process()
- get_logger(), log_to_stderr()
- Programming guidelines
- 多个Python进程有各自独立的GIL锁,互不影响
- 多线程
- thread
- threading
- Thread
- current_thread()
- Lock
- ThreadLocal
- 多线程编程,模型复杂,容易发生冲突,必须用锁加以隔离,同时,又要小心死锁的发生
- 架构
- Master-Worker
- 进程
- 线程
- 计算密集 vs IO密集