Fix assertion "Someone released me too many times: too many tokens!" when more
than one process was running at the same time. This was caused by the override of SharedPool.__new__ not stopping ProcessPool.__init__ from being run whenever process.simple_execute is called. When __init__ ran for the second time, the DeferredSemaphore was replaced, and this meant that we ended up releasing a different semaphore to the one that was acquired.
This commit is contained in:
		| @@ -205,13 +205,12 @@ class ProcessPool(object): | ||||
|         self._pool.release() | ||||
|         return rv | ||||
|  | ||||
| class SharedPool(ProcessPool): | ||||
|     _instance = None | ||||
|     def __new__(cls, *args, **kwargs): | ||||
|         if not cls._instance: | ||||
|             cls._instance = super(SharedPool, cls).__new__( | ||||
|                     cls, *args, **kwargs) | ||||
|         return cls._instance | ||||
| _instance = None | ||||
| def SharedPool(): | ||||
|     global _instance | ||||
|     if _instance is None: | ||||
|        _instance = ProcessPool() | ||||
|     return _instance | ||||
|  | ||||
| def simple_execute(cmd, **kwargs): | ||||
|     return SharedPool().simple_execute(cmd, **kwargs) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Ewan Mellor
					Ewan Mellor