Skip to content

Commit

Permalink
Since the internal bin_in_path() function is called a lot, a cache was
Browse files Browse the repository at this point in the history
a good thing to implement.

git-svn-id: svn://cherokee-project.com/cherokee/trunk@5964 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information
alobbs committed Dec 17, 2010
1 parent 209f15b commit cad13d8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cherokee/cherokee-admin-launcher
Expand Up @@ -173,14 +173,25 @@ def http_GET_admin (host=ADMIN_HOST, port=ADMIN_PORT, req='/'):
return content


_bin_in_path_cache = {}
def bin_in_path (bin):
global _bin_in_path_cache

# Cache hit
if bin in _bin_in_path_cache:
return _bin_in_path_cache[bin]

# Cache miss: check it out
paths = os.getenv('PATH').split(':') + DEFAULT_PATHS

for e in paths:
fp = os.path.join (e, bin)
if os.access (fp, os.X_OK):
_bin_in_path_cache[bin] = True
return fp

_bin_in_path_cache[bin] = False


def launch_browser (url, user, password):
if user and password:
Expand Down

0 comments on commit cad13d8

Please sign in to comment.