File tree Expand file tree Collapse file tree
src/clusterfuzz/_internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,16 +51,21 @@ def context():
5151 # multiprocessing.set_start_method to not fork.
5252 context_module ._state .context = None # pylint: disable=protected-access
5353
54- with _client ().context () as ndb_context :
55- # Disable NDB caching, as NDB on GCE VMs do not use memcache and therefore
56- # can't invalidate the memcache cache.
57- ndb_context .set_memcache_policy (False )
54+ current_context = context_module .get_context (False )
55+ if current_context :
56+ yield current_context
5857
59- # Disable the in-context cache, as it can use up a lot of memory for
60- # longer running tasks such as cron jobs.
61- ndb_context .set_cache_policy (False )
58+ else :
59+ with _client ().context () as ndb_context :
60+ # Disable NDB caching, as NDB on GCE VMs do not use memcache and therefore
61+ # can't invalidate the memcache cache.
62+ ndb_context .set_memcache_policy (False )
6263
63- yield ndb_context
64+ # Disable the in-context cache, as it can use up a lot of memory for
65+ # longer running tasks such as cron jobs.
66+ ndb_context .set_cache_policy (False )
67+
68+ yield ndb_context
6469
6570
6671def thread_wrapper (func ):
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ class KubernetesJobClientTest(unittest.TestCase):
3232
3333 def setUp (self ):
3434 helpers .patch (self , [
35+ 'clusterfuzz._internal.k8s.service.KubernetesService._load_gke_credentials' ,
3536 'kubernetes.config.load_kube_config' ,
3637 'kubernetes.client.CoreV1Api' ,
3738 'kubernetes.client.BatchV1Api' ,
You can’t perform that action at this time.
0 commit comments