Statistics
| Branch: | Tag: | Revision:

root / snf-pithos-backend / pithos / backends / __init__.py @ fda50d75

History | View | Annotate | Download (2.2 kB)

1 2e662088 Antony Chazapis
# Copyright 2011-2012 GRNET S.A. All rights reserved.
2 2715ade4 Sofia Papagiannaki
#
3 5635f9ef Antony Chazapis
# Redistribution and use in source and binary forms, with or
4 5635f9ef Antony Chazapis
# without modification, are permitted provided that the following
5 5635f9ef Antony Chazapis
# conditions are met:
6 f3b8de1a Kostas Papadimitriou
#
7 5635f9ef Antony Chazapis
#   1. Redistributions of source code must retain the above
8 5635f9ef Antony Chazapis
#      copyright notice, this list of conditions and the following
9 5635f9ef Antony Chazapis
#      disclaimer.
10 f3b8de1a Kostas Papadimitriou
#
11 5635f9ef Antony Chazapis
#   2. Redistributions in binary form must reproduce the above
12 5635f9ef Antony Chazapis
#      copyright notice, this list of conditions and the following
13 5635f9ef Antony Chazapis
#      disclaimer in the documentation and/or other materials
14 5635f9ef Antony Chazapis
#      provided with the distribution.
15 f3b8de1a Kostas Papadimitriou
#
16 5635f9ef Antony Chazapis
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 5635f9ef Antony Chazapis
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 5635f9ef Antony Chazapis
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 5635f9ef Antony Chazapis
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 5635f9ef Antony Chazapis
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 5635f9ef Antony Chazapis
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 5635f9ef Antony Chazapis
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 5635f9ef Antony Chazapis
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 5635f9ef Antony Chazapis
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 5635f9ef Antony Chazapis
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 5635f9ef Antony Chazapis
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 5635f9ef Antony Chazapis
# POSSIBILITY OF SUCH DAMAGE.
28 f3b8de1a Kostas Papadimitriou
#
29 5635f9ef Antony Chazapis
# The views and conclusions contained in the software and
30 5635f9ef Antony Chazapis
# documentation are those of the authors and should not be
31 5635f9ef Antony Chazapis
# interpreted as representing official policies, either expressed
32 5635f9ef Antony Chazapis
# or implied, of GRNET S.A.
33 5635f9ef Antony Chazapis
34 8c793655 Antony Chazapis
import warnings
35 8c793655 Antony Chazapis
36 fda50d75 Chrysostomos Nanakos
from pithos.workers import glue
37 fda50d75 Chrysostomos Nanakos
from archipelago.common import Segment, Xseg_ctx
38 fda50d75 Chrysostomos Nanakos
from objpool import ObjectPool
39 fda50d75 Chrysostomos Nanakos
from pithos.api.settings import BACKEND_ARCHIPELAGO_CONF as cfile
40 fda50d75 Chrysostomos Nanakos
41 fda50d75 Chrysostomos Nanakos
glue.WorkerGlue.setupXsegPool(ObjectPool, Segment, Xseg_ctx, cfile,
42 fda50d75 Chrysostomos Nanakos
                              pool_size=8)
43 fda50d75 Chrysostomos Nanakos
44 39593b2b Giorgos Verigakis
45 228de81b Antony Chazapis
def connect_backend(**kwargs):
46 3d81935f Vangelis Koukis
    from pithos.backends.modular import ModularBackend
47 3d81935f Vangelis Koukis
48 8c793655 Antony Chazapis
    # Suppress mysql warnings.
49 8c793655 Antony Chazapis
    original_filters = warnings.filters[:]
50 8c793655 Antony Chazapis
    warnings.simplefilter('ignore')
51 8c793655 Antony Chazapis
    try:
52 228de81b Antony Chazapis
        backend = ModularBackend(**kwargs)
53 8c793655 Antony Chazapis
    finally:
54 8c793655 Antony Chazapis
        # Restore warnings.
55 8c793655 Antony Chazapis
        warnings.filters = original_filters
56 f3b8de1a Kostas Papadimitriou
57 8c793655 Antony Chazapis
    return backend