Module ncs.pool
Resource Pool
Classes
class Pool (log, name, cfg, item_cb)
-
Size restricted resource pool.
Methods
def maintenance(self)
-
Resource maintenance, times out idle items.
def return_item(self, cb_item, is_failed=False)
-
Return item to pool.
Set is_failed to True whenever a operation failed while using this item to ensure the item is not re-used.
def stop(self)
-
Stop Pool, deletes all items and disallows enqueue of new items.
def take_item(self)
-
Take, and if required create, item from pool.
Takes idle item or creates new one if none exists. If max size is reached call will block until item is available OR pool is stopped.
None return value indicates that the pool is stopped.
class PoolConfig (min_size, max_size, idle_timeout_s)
-
Size and time configuration for Pool.
Instance variables
var idle_timeout_s
-
Return an attribute of instance, which is of type owner.
var max_size
-
Return an attribute of instance, which is of type owner.
var min_size
-
Return an attribute of instance, which is of type owner.
class PoolItemCb (log)
-
Subclasses
- ncs.application._MaapiCb
- ncs.dp._WsockCb
Methods
def create_item(self)
-
Create new item.
def delete_item(self, item)
-
Free resources used by item.
def return_item(self, item)
-
Mark item as available in the pool.
def take_item(self, item)
-
Mark item as taken from the pool.
class ThreadPool (log, name, cfg, item_cb)
-
Thread pool executing callables on associated data items.
Subclasses
- ncs.dp._WthreadPool
Methods
def enqueue(self, fun, name)
-
Enqueue fun to execute in pool
def start(self)
-
Start ThreadPool
def stop(self)
-
Stop ThreadPool and all worker threads