possible to fix to memdb threading issue
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.7.4-stable+timestamp.2013.11.11.17.41.59
|
Version 2.7.4-stable+timestamp.2013.11.13.14.06.31
|
||||||
|
|||||||
+2
-13
@@ -20,6 +20,7 @@ import cStringIO
|
|||||||
import csv
|
import csv
|
||||||
import copy
|
import copy
|
||||||
import gluon.validators as validators
|
import gluon.validators as validators
|
||||||
|
from gluon.utils import web2py_uuid
|
||||||
from gluon.storage import Storage
|
from gluon.storage import Storage
|
||||||
from gluon import SQLTABLE
|
from gluon import SQLTABLE
|
||||||
import random
|
import random
|
||||||
@@ -279,22 +280,11 @@ class Table(DALStorage):
|
|||||||
def delete(self, id):
|
def delete(self, id):
|
||||||
return self._tableobj.delete(self._id_to_key(id))
|
return self._tableobj.delete(self._id_to_key(id))
|
||||||
|
|
||||||
def _shard_key(self, shard):
|
|
||||||
return self._id_to_key('s/%s' % shard)
|
|
||||||
|
|
||||||
def _id_to_key(self, id):
|
def _id_to_key(self, id):
|
||||||
return '__memdb__/t/%s/k/%s' % (self._tablename, str(id))
|
return '__memdb__/t/%s/k/%s' % (self._tablename, str(id))
|
||||||
|
|
||||||
def _create_id(self):
|
def _create_id(self):
|
||||||
shard = random.randint(10, 99)
|
return long(web2py_uuid().replace('-',''),16)
|
||||||
shard_id = self._shard_key(shard)
|
|
||||||
id = self._tableobj.incr(shard_id)
|
|
||||||
if not id:
|
|
||||||
if self._tableobj.set(shard_id, '0'):
|
|
||||||
id = 0
|
|
||||||
else:
|
|
||||||
raise Exception('cannot set memcache')
|
|
||||||
return long(str(shard) + str(id))
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self._tablename
|
return self._tablename
|
||||||
@@ -302,7 +292,6 @@ class Table(DALStorage):
|
|||||||
def __call__(self, id):
|
def __call__(self, id):
|
||||||
return self.get(id)
|
return self.get(id)
|
||||||
|
|
||||||
|
|
||||||
class Expression(object):
|
class Expression(object):
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|||||||
Reference in New Issue
Block a user