the package used to manage resources in the resource pool.
Project description
changelist
- 4.0.0, when timeout, throws TimeoutError in the test running thread other than Timer Thread
- 3.0.1, give thread a name for timer thread in the Device and DevicePool.so you can see which thread is free thread
- 3.0.0, add force free: when time is up, the subthread in Device and DevicePool will free resource automatically
- 2.3.2, update readme
- 2.3.1, add free function for Device, so you can free Device by call free()
- 2.3.0, add size property for DevicePool, so you can know how many available resources in the pool
- 2.2.2, fix readme problem
- 2.2.1, fix readme problem
- 2.2.0, make device returned by devicepool writtable but can modify the attribute assigned from DevicePool
- 2.1.0, make device returned by devicepool readonly
feedback
- send email to dvdface@gmail.com
- visit https://github.com/dvdface/devicepool
how to install
pip install devicepool
how to use
- import library first
from devicepool import Device, DevicePool
- make a resource dict list
resource_list = [ { 'ip': '192.168.1.1', 'type': 'android' }, { 'ip': '192.168.1.2', 'type': 'ios' } ]
- init devicepool
devicepool = DevicePool(resource_list)
- get a device from the pool
# know how many available resource in the pool devicepool.size # 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) # specify rent time, default is 120 sec dev = devicepool.get(rent_time=360)
- 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')
- use the device by dot way
print(dev.ip) print(dev.type)
- free the device, or let't it free automatically
dev.free()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
devicepool-4.0.0.tar.gz
(4.0 kB
view details)
File details
Details for the file devicepool-4.0.0.tar.gz
.
File metadata
- Download URL: devicepool-4.0.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 663140b91cbba42f6a54736ce805aab154651c459dd07e7a0242a60943cb37dc |
|
MD5 | e7263e172188b53c503763babae1561f |
|
BLAKE2b-256 | 44439bb1d3539b766851cb0ac27c0911b3d437ceab48a311be9087ffea61b300 |