projects
/
arvados.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0582d77
)
Add threading locks in Keep client
author
Tom Clegg <tom@clinicalfuture.com>
Tue, 19 Nov 2013 09:04:58 +0000
(
01:04
-0800)
committer
Tom Clegg <tom@clinicalfuture.com>
Tue, 19 Nov 2013 09:05:48 +0000
(
01:05
-0800)
sdk/python/arvados.py
patch
|
blob
|
history
diff --git
a/sdk/python/arvados.py
b/sdk/python/arvados.py
index 4d7f2d845c8fe0fbe0008010ed6577215c4cf561..ebe6bf3121aa07d11292c71d34d9b3ced4074fc4 100644
(file)
--- a/
sdk/python/arvados.py
+++ b/
sdk/python/arvados.py
@@
-16,6
+16,7
@@
import bz2
import zlib
import fcntl
import time
import zlib
import fcntl
import time
+import threading
from apiclient import errors
from apiclient.discovery import build
from apiclient import errors
from apiclient.discovery import build
@@
-789,10
+790,12
@@
class Keep:
class KeepClient:
def __init__(self):
class KeepClient:
def __init__(self):
+ self.lock = threading.Lock()
self.service_roots = None
def shuffled_service_roots(self, hash):
if self.service_roots == None:
self.service_roots = None
def shuffled_service_roots(self, hash):
if self.service_roots == None:
+ self.lock.acquire()
keep_disks = api().keep_disks().list().execute()['items']
roots = (("http%s://%s:%d/" %
('s' if f['service_ssl_flag'] else '',
keep_disks = api().keep_disks().list().execute()['items']
roots = (("http%s://%s:%d/" %
('s' if f['service_ssl_flag'] else '',
@@
-801,6
+804,7
@@
class KeepClient:
for f in keep_disks)
self.service_roots = sorted(set(roots))
logging.debug(str(self.service_roots))
for f in keep_disks)
self.service_roots = sorted(set(roots))
logging.debug(str(self.service_roots))
+ self.lock.release()
seed = hash
pool = self.service_roots[:]
pseq = []
seed = hash
pool = self.service_roots[:]
pseq = []