Skip to content

Commit

Permalink
added async_write option to data_helper
Browse files Browse the repository at this point in the history
added async_write option to data_helper

Change-Id: Ia844d816de893b76f7289698fc47567aef6128fe
  • Loading branch information
farshidce committed Jun 5, 2011
1 parent c0d2a86 commit 27b7c7e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
20 changes: 15 additions & 5 deletions lib/memcached/helper/data_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def create_threads(servers=None,
number_of_threads=50,
override_vBucketId=-1,
write_only=False,
moxi=True):
moxi=True,
async_write=True):
log = logger.Logger.get_logger()
if not servers:
raise MemcachedClientHelperExcetion(errorcode='invalid_argument',
Expand Down Expand Up @@ -80,7 +81,8 @@ def create_threads(servers=None,
ignore_how_many_errors=5000,
override_vBucketId=override_vBucketId,
write_only=write_only,
moxi=moxi)
moxi=moxi,
async_write=async_write)
threads.append(thread)

return threads
Expand Down Expand Up @@ -397,7 +399,8 @@ def __init__(self,
override_vBucketId=-1,
terminate_in_minutes=60,
write_only=False,
moxi=True):
moxi=True,
async_write=False):
threading.Thread.__init__(self)
self.log = logger.Logger.get_logger()
self.serverInfo = serverInfo
Expand Down Expand Up @@ -425,6 +428,7 @@ def __init__(self,
'baseuuid': self._base_uuid}
self.write_only = write_only
self.aborted = False
self.async_write = async_write

def inserted_keys_count(self):
return self._inserted_keys_count
Expand Down Expand Up @@ -505,7 +509,10 @@ def run(self):
try:
if self.override_vBucketId >= 0:
client.vbucketId = self.override_vBucketId
client.set(key, 0, 0, selected['value'])
if self.async_write:
client.send_set(key, 0, 0, selected['value'])
else:
client.set(key, 0, 0, selected['value'])
self._inserted_keys_count += 1
backoff_count = 0
except MemcachedError as error:
Expand Down Expand Up @@ -559,7 +566,10 @@ def run(self):
try:
if self.override_vBucketId >= 0:
client.vbucketId = self.override_vBucketId
client.set(key, 0, 0, key)
if self.async_write:
client.send_set(key, 0, 0, selected['value'])
else:
client.set(key, 0, 0, selected['value'])
self._inserted_keys_count += 1
except MemcachedError:
self._rejected_keys_count += 1
Expand Down
3 changes: 2 additions & 1 deletion pytests/combotests.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def common_test_body(self, replica, load_ratio, timeout=10):
number_of_threads=20,
number_of_items=4000000000,
moxi=False,
write_only=True)
write_only=True,
async_write=True)
for thread in threads:
thread.start()
while time.time() < ( start_time + 60 * timeout):
Expand Down

0 comments on commit 27b7c7e

Please sign in to comment.