This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/2502 Resource.find: allow returning empty instead of raising Add flag raise_if_missing, and if False, instead of raising an exception, return an empty list for that kind of resource. This makes sense for a caller that requests a single resource. When finding a single resource to use in ReservedResources.get(), use this to raise a more adequate exception message if none was found. Change-Id: Ia296ea68a787bede037a6cea38563b570fb0766e --- M src/osmo_gsm_tester/resource.py 1 file changed, 14 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/02/2502/1 diff --git a/src/osmo_gsm_tester/resource.py b/src/osmo_gsm_tester/resource.py index 2b7e3e1..699b465 100644 --- a/src/osmo_gsm_tester/resource.py +++ b/src/osmo_gsm_tester/resource.py @@ -321,13 +321,22 @@ if item_matches(my_item, want_item, ignore_keys=('times',)): item_match_list.append(i) if not item_match_list: - raise NoResourceExn('No matching resource available for %s = %r' - % (key, want_item)) + if raise_if_missing: + raise NoResourceExn('No matching resource available for %s = %r' + % (key, want_item)) + else: + # this one failed... see below + all_matches = [] + break + all_matches.append( item_match_list ) if not all_matches: - raise NoResourceExn('No matching resource available for %s = %r' - % (key, want_list)) + # ...this one failed. Makes no sense to solve resource + # allocations, return an empty list for this key to mark + # failure. + matches[key] = [] + continue # figure out who gets what solution = solve(all_matches) @@ -450,7 +459,7 @@ specifics = {} self.dbg('requesting use of', kind, specifics=specifics) want = { kind: [specifics] } - available_dict = self.reserved.find(want, skip_if_marked=USED_KEY, do_copy=False) + available_dict = self.reserved.find(want, skip_if_marked=USED_KEY, do_copy=False, raise_if_missing=False) available = available_dict.get(kind) self.dbg(available=len(available)) if not available: -- To view, visit https://gerrit.osmocom.org/2502 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia296ea68a787bede037a6cea38563b570fb0766e Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-tester Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>