Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: appengine/config_service/projects.py

Issue 2934783004: config_service: use == for sentinel value (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The LUCI Authors. All rights reserved. 1 # Copyright 2015 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 """Provides info about projects (service tenants).""" 5 """Provides info about projects (service tenants)."""
6 6
7 import logging 7 import logging
8 8
9 from google.appengine.api import memcache 9 from google.appengine.api import memcache
10 from google.appengine.ext import ndb 10 from google.appengine.ext import ndb
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 pid: ctx.memcache_get(pid, namespace=cache_ns) 108 pid: ctx.memcache_get(pid, namespace=cache_ns)
109 for pid in project_ids 109 for pid in project_ids
110 } 110 }
111 yield cache_futs.values() 111 yield cache_futs.values()
112 result = {} 112 result = {}
113 missing = [] 113 missing = []
114 for pid in project_ids: 114 for pid in project_ids:
115 binary = cache_futs[pid].get_result() 115 binary = cache_futs[pid].get_result()
116 if binary is not None: 116 if binary is not None:
117 # cache hit 117 # cache hit
118 if binary is PROJECT_DOES_NOT_EXIST_SENTINEL: 118 if binary == PROJECT_DOES_NOT_EXIST_SENTINEL:
119 result[pid] = None 119 result[pid] = None
120 else: 120 else:
121 cfg = project_config_pb2.ProjectCfg() 121 cfg = project_config_pb2.ProjectCfg()
122 cfg.ParseFromString(binary) 122 cfg.ParseFromString(binary)
123 result[pid] = cfg 123 result[pid] = cfg
124 else: 124 else:
125 # cache miss 125 # cache miss
126 missing.append(pid) 126 missing.append(pid)
127 127
128 if missing: 128 if missing:
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 # TODO(nodir): optimize 188 # TODO(nodir): optimize
189 assert isinstance(project_ids, list) 189 assert isinstance(project_ids, list)
190 if not project_ids: 190 if not project_ids:
191 return project_ids 191 return project_ids
192 assert all(pid for pid in project_ids) 192 assert all(pid for pid in project_ids)
193 all_project_ids = set(p.id for p in get_projects()) 193 all_project_ids = set(p.id for p in get_projects())
194 return [ 194 return [
195 pid for pid in project_ids 195 pid for pid in project_ids
196 if pid in all_project_ids 196 if pid in all_project_ids
197 ] 197 ]
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698