Skip to content

Commit

Permalink
Don't import all keyrings unless necessary (#404)
Browse files Browse the repository at this point in the history
If a keyring is set in configuration or environment variables,
use that one and don't load all available keyrings.
  • Loading branch information
jyn514 authored and mitya57 committed Oct 30, 2019
1 parent 248535d commit a62c1c6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions keyring/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ def init_backend(limit=None):
# save the limit for the chainer to honor
backend._limit = limit

# get all keyrings passing the limit filter
keyrings = filter(limit, backend.get_all_keyring())

set_keyring(
load_env()
or load_config()
or max(keyrings, default=fail.Keyring(), key=backend.by_priority)
# get all keyrings passing the limit filter
or max(
filter(limit, backend.get_all_keyring()),
default=fail.Keyring(),
key=backend.by_priority,
)
)


Expand Down

0 comments on commit a62c1c6

Please sign in to comment.