equal
deleted
inserted
replaced
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 |
18 |
19 from datetime import datetime |
19 from datetime import datetime |
20 from threading import Thread |
20 from threading import Thread |
|
21 |
|
22 from six.moves import range |
21 |
23 |
22 from logilab.common.testlib import SkipTest |
24 from logilab.common.testlib import SkipTest |
23 |
25 |
24 from cubicweb import ValidationError |
26 from cubicweb import ValidationError |
25 from cubicweb.devtools import PostgresApptestConfiguration, startpgcluster, stoppgcluster |
27 from cubicweb.devtools import PostgresApptestConfiguration, startpgcluster, stoppgcluster |
53 # concurrent allocation of eid ranges |
55 # concurrent allocation of eid ranges |
54 source = self.session.repo.sources_by_uri['system'] |
56 source = self.session.repo.sources_by_uri['system'] |
55 range1 = [] |
57 range1 = [] |
56 range2 = [] |
58 range2 = [] |
57 def allocate_eid_ranges(session, target): |
59 def allocate_eid_ranges(session, target): |
58 for x in xrange(1, 10): |
60 for x in range(1, 10): |
59 eid = source.create_eid(session, count=x) |
61 eid = source.create_eid(session, count=x) |
60 target.extend(range(eid-x, eid)) |
62 target.extend(range(eid-x, eid)) |
61 |
63 |
62 t1 = Thread(target=lambda: allocate_eid_ranges(self.session, range1)) |
64 t1 = Thread(target=lambda: allocate_eid_ranges(self.session, range1)) |
63 t2 = Thread(target=lambda: allocate_eid_ranges(self.session, range2)) |
65 t2 = Thread(target=lambda: allocate_eid_ranges(self.session, range2)) |