server/repository.py
changeset 10608 7fc548d9dd8e
parent 10589 7c23b7de2b8d
child 10609 e2d8e81bfe68
equal deleted inserted replaced
10607:6519ae8cca0c 10608:7fc548d9dd8e
    28 from __future__ import print_function
    28 from __future__ import print_function
    29 
    29 
    30 __docformat__ = "restructuredtext en"
    30 __docformat__ = "restructuredtext en"
    31 
    31 
    32 import threading
    32 import threading
    33 import Queue
       
    34 from warnings import warn
    33 from warnings import warn
    35 from itertools import chain
    34 from itertools import chain
    36 from time import time, localtime, strftime
    35 from time import time, localtime, strftime
    37 from contextlib import contextmanager
    36 from contextlib import contextmanager
       
    37 
       
    38 from six.moves import queue
    38 
    39 
    39 from logilab.common.decorators import cached, clear_cache
    40 from logilab.common.decorators import cached, clear_cache
    40 from logilab.common.deprecation import deprecated
    41 from logilab.common.deprecation import deprecated
    41 
    42 
    42 from yams import BadSchemaDefinition
    43 from yams import BadSchemaDefinition
   197                     session.user.__class__ = usercls
   198                     session.user.__class__ = usercls
   198 
   199 
   199     def init_cnxset_pool(self):
   200     def init_cnxset_pool(self):
   200         """should be called bootstrap_repository, as this is what it does"""
   201         """should be called bootstrap_repository, as this is what it does"""
   201         config = self.config
   202         config = self.config
   202         self._cnxsets_pool = Queue.Queue()
   203         self._cnxsets_pool = queue.Queue()
   203         # 0. init a cnxset that will be used to fetch bootstrap information from
   204         # 0. init a cnxset that will be used to fetch bootstrap information from
   204         #    the database
   205         #    the database
   205         self._cnxsets_pool.put_nowait(self.system_source.wrapped_connection())
   206         self._cnxsets_pool.put_nowait(self.system_source.wrapped_connection())
   206         # 1. set used cubes
   207         # 1. set used cubes
   207         if config.creating or not config.read_instance_schema:
   208         if config.creating or not config.read_instance_schema:
   377 
   378 
   378     #@locked
   379     #@locked
   379     def _get_cnxset(self):
   380     def _get_cnxset(self):
   380         try:
   381         try:
   381             return self._cnxsets_pool.get(True, timeout=5)
   382             return self._cnxsets_pool.get(True, timeout=5)
   382         except Queue.Empty:
   383         except queue.Empty:
   383             raise Exception('no connections set available after 5 secs, probably either a '
   384             raise Exception('no connections set available after 5 secs, probably either a '
   384                             'bug in code (too many uncommited/rolled back '
   385                             'bug in code (too many uncommited/rolled back '
   385                             'connections) or too much load on the server (in '
   386                             'connections) or too much load on the server (in '
   386                             'which case you can try to set a bigger '
   387                             'which case you can try to set a bigger '
   387                             'connections pool size)')
   388                             'connections pool size)')