| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Resource locking module for python.
Originally designed for following projects:
Module provides python API and simple CLI interface.
Resource is released in following cases:
Resources data provider support following mechanisms:
% lockable --help
usage: lockable [-h] [--validate-only] [--lock-folder LOCK_FOLDER] [--resources RESOURCES]
[--timeout TIMEOUT] [--hostname HOSTNAME]
[--requirements REQUIREMENTS]
[command [command ...]]
run given command while suitable resource is allocated.
Usage example: lockable --requirements {"online":true} echo using resource: $ID
positional arguments:
command Command to be execute during device allocation
optional arguments:
-h, --help show this help message and exit
--validate-only Only validate resources.json
--lock-folder LOCK_FOLDER
lock folder
--resources RESOURCES
Resources file (utf-8) or http uri
--timeout TIMEOUT Timeout for trying allocate suitable resource
--hostname HOSTNAME Hostname
--requirements REQUIREMENTS
requirements as json string
Constructor
lockable = Lockable([hostname], [resource_list_file], [resource_list], [lock_folder])Allocation
allocation_context = lockable.lock(requirements, [timeout_s])
print(allocation_context.resource_info)
print(allocation_context.resource_id)
allocation_context.unlock()
# or using resource info
lockable.unlock(allocation_context)Allocation context contains following API:
or using context manager which unlock automatically
with lockable.auto_lock(requirements, [timeout_s]) as allocation:
print(allocation.resource_info)Resource requirements are evaluated using mongoquery, so MongoDB-style operators like $in and $gt are supported when selecting resources.
Tips:
You can allocate also offline devices by set requirements "online": None . You can ignore also hostname same same way by setting it to None`
| Back | FazBrowse Home | New Git URL |