Skip to main content

the package used to manage resources in the resource pool.

Project description

changelist

2.1.0, make device returned by devicepool readonly

feedback

how to install

pip install devicepool

how to use

  1. import library first from devicepool import Device, DevicePool
  2. make a resource dict list
resource_list = [
	{
		'ip':	'192.168.1.1',
		'type': 'android'
	},
	
	{
		'ip':	'192.168.1.2',
		'type': 'ios'
	}
]
  1. init devicepool
devicepool = DevicePool(resource_list)
  1. get a device from the pool
# allocate any dev from resource pool
dev = devicepool.get()

# use filter_func to get desired resource, for exmaple type == 'android'
dev = devicepool.get(filter_func=lambda dev: dev.type == 'android')

# use timeout to wait, default timeout is zero
dev = devicepool.get(timeout=10)
  1. check if allocating device is successfully
# if resource is not enougth and timeout, return None
# so you need check if dev is None
if dev == None:
	print('allocate resource failed')
  1. use the device by dot way
print(dev.ip)
print(dev.type)
  1. free the device, or let't it free automatically
del dev

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

devicepool-2.1.0.tar.gz (3.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page