<commit_before># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import threading
import socket
import contextlib
import pika

from configman.config_manager import RequiredConfig
from configman import Namespace


class Connection(object):
    """A facade around a RabbitMQ channel that standardizes certain gross
    elements of its API with those of other connection types."""

    def __init__(self, config, connection):
        """Construct.

        parameters:
            config - A configman config
            connection - A RabbitMQ BlockingConnection from which we can derive
                channels
        """
        self.config = config
        self.channel = connection.channel()
        self.channel.queue_declare(queue='socorro.normal', durable=True)
        self.channel.queue_declare(queue="socorro.priority", durable=True)
        # I'm not very happy about things having to reach inside me and prod
        # self.channel directly to get anything done, but I think there's a
        # greater architectural issue to solve here: none of these Connection
        # objects abstract their connections fully.

    def commit(self):
        pass

    def rollback(self):
        pass

    def close(self):
        self.transport.close()


class ConnectionContext(RequiredConfig):
    """a configman compliant class for setup of RabbitMQ connections"""
    #--------------------------------------------------------------------------
    # configman parameter definition section
    # here we're setting up the minimal parameters required for connecting
    # to a RabbitMQ server.
    required_config = Namespace()
    required_config.add_option(<commit_msg>Use connection instead of transport to close()<commit_after># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import threading
import socket
import contextlib
import pika

from configman.config_manager import RequiredConfig
from configman import Namespace


class Connection(object):
    """A facade around a RabbitMQ channel that standardizes certain gross
    elements of its API with those of other connection types."""

    def __init__(self, config, connection):
        """Construct.

        parameters:
            config - A configman config
            connection - A RabbitMQ BlockingConnection from which we can derive
                channels
        """
        self.config = config
        self.connection = connection
        self.channel = connection.channel()
        self.channel.queue_declare(queue='socorro.normal', durable=True)
        self.channel.queue_declare(queue="socorro.priority", durable=True)
        # I'm not very happy about things having to reach inside me and prod
        # self.channel directly to get anything done, but I think there's a
        # greater architectural issue to solve here: none of these Connection
        # objects abstract their connections fully.

    def commit(self):
        pass

    def rollback(self):
        pass

    def close(self):
        self.connection.close()


class ConnectionContext(RequiredConfig):
    """a configman compliant class for setup of RabbitMQ connections"""
    #--------------------------------------------------------------------------
    # configman parameter definition section
    # here we're setting up the minimal parameters required for connecting
    # to a RabbitMQ server.
    required_config = Namespace()
    required_config.add_option(
{'fraction_non_alphanumeric': 0.10325356278569509, 'fraction_numerical': 0.0021511158913686476, 'mean_word_length': 2.539486203615604, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2882778', 'n_tokens_mistral': 907, 'n_tokens_neox': 847, 'n_words': 369}