~pythonregexp2.7/python/issue2636-09-01+10

« back to all changes in this revision

Viewing changes to Lib/bsddb/test/test_distributed_transactions.py

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-09-22 21:39:45 UTC
  • mfrom: (39055.1.33 Regexp-2.7)
  • Revision ID: darklord@timehorse.com-20080922213945-23717m5eiqpamcyn
Merged in changes from the Single-Loop Engine branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
import os
5
5
import unittest
6
6
 
7
 
try:
8
 
    # For Pythons w/distutils pybsddb
9
 
    from bsddb3 import db
10
 
except ImportError:
11
 
    # For Python 2.3
12
 
    from bsddb import db
13
 
 
14
 
from test_all import get_new_environment_path, get_new_database_path
15
 
 
16
 
try:
17
 
    from bsddb3 import test_support
18
 
except ImportError:
19
 
    from test import test_support
 
7
from test_all import db, test_support, get_new_environment_path, \
 
8
        get_new_database_path
20
9
 
21
10
try :
22
11
    a=set()
79
68
 
80
69
    def test01_distributed_transactions(self) :
81
70
        txns=set()
 
71
        adapt = lambda x : x
 
72
        import sys
 
73
        if sys.version_info[0] >= 3 :
 
74
            adapt = lambda x : bytes(x, "ascii")
82
75
    # Create transactions, "prepare" them, and
83
76
    # let them be garbage collected.
84
77
        for i in xrange(self.num_txns) :
85
 
            txn=self.dbenv.txn_begin()
86
 
            gid="%%%dd" %db.DB_XIDDATASIZE
87
 
            gid=gid %i
 
78
            txn = self.dbenv.txn_begin()
 
79
            gid = "%%%dd" %db.DB_XIDDATASIZE
 
80
            gid = adapt(gid %i)
88
81
            self.db.put(i, gid, txn=txn, flags=db.DB_APPEND)
89
82
            txns.add(gid)
90
83
            txn.prepare(gid)