| OLD | NEW |
| 1 # This file is part of Buildbot. Buildbot is free software: you can | 1 # This file is part of Buildbot. Buildbot is free software: you can |
| 2 # redistribute it and/or modify it under the terms of the GNU General Public | 2 # redistribute it and/or modify it under the terms of the GNU General Public |
| 3 # License as published by the Free Software Foundation, version 2. | 3 # License as published by the Free Software Foundation, version 2. |
| 4 # | 4 # |
| 5 # This program is distributed in the hope that it will be useful, but WITHOUT | 5 # This program is distributed in the hope that it will be useful, but WITHOUT |
| 6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 8 # details. | 8 # details. |
| 9 # | 9 # |
| 10 # You should have received a copy of the GNU General Public License along with | 10 # You should have received a copy of the GNU General Public License along with |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 u.database = u.database % dict(basedir = kwargs['basedir']) | 76 u.database = u.database % dict(basedir = kwargs['basedir']) |
| 77 if not os.path.isabs(u.database[0]): | 77 if not os.path.isabs(u.database[0]): |
| 78 u.database = os.path.join(kwargs['basedir'], u.database) | 78 u.database = os.path.join(kwargs['basedir'], u.database) |
| 79 | 79 |
| 80 # in-memory databases need exactly one connection | 80 # in-memory databases need exactly one connection |
| 81 if not u.database: | 81 if not u.database: |
| 82 kwargs['pool_size'] = 1 | 82 kwargs['pool_size'] = 1 |
| 83 max_conns = 1 | 83 max_conns = 1 |
| 84 | 84 |
| 85 # allow serializing access to the db | |
| 86 if 'serialize_access' in u.query: | |
| 87 u.query.pop('serialize_access') | |
| 88 max_conns = 1 | |
| 89 | |
| 90 return u, kwargs, max_conns | 85 return u, kwargs, max_conns |
| 91 | 86 |
| 92 def set_up_sqlite_engine(self, u, engine): | 87 def set_up_sqlite_engine(self, u, engine): |
| 93 """Special setup for sqlite engines""" | 88 """Special setup for sqlite engines""" |
| 94 # try to enable WAL logging | 89 # try to enable WAL logging |
| 95 if u.database: | 90 if u.database: |
| 96 log.msg("setting database journal mode to 'wal'") | 91 log.msg("setting database journal mode to 'wal'") |
| 97 try: | 92 try: |
| 98 engine.execute("pragma journal_mode = wal") | 93 engine.execute("pragma journal_mode = wal") |
| 99 except: | 94 except: |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 169 |
| 175 BuildbotEngineStrategy() | 170 BuildbotEngineStrategy() |
| 176 | 171 |
| 177 # this module is really imported for the side-effects, but pyflakes will like | 172 # this module is really imported for the side-effects, but pyflakes will like |
| 178 # us to use something from the module -- so offer a copy of create_engine, which | 173 # us to use something from the module -- so offer a copy of create_engine, which |
| 179 # explicitly adds the strategy argument | 174 # explicitly adds the strategy argument |
| 180 def create_engine(*args, **kwargs): | 175 def create_engine(*args, **kwargs): |
| 181 kwargs['strategy'] = 'buildbot' | 176 kwargs['strategy'] = 'buildbot' |
| 182 | 177 |
| 183 return sqlalchemy.create_engine(*args, **kwargs) | 178 return sqlalchemy.create_engine(*args, **kwargs) |
| OLD | NEW |