<commit_before># coding=utf-8
from logging import getLogger
from random import randint
from threading import Thread

from django.contrib.auth.models import User
from django.core.mail import EmailMessage
from django.core.urlresolvers import reverse

from .models import Subscription

log = getLogger(__name__)


def _mail(recipients, subject, body):
    def mail():
        it = randint(0, 0x10000)
        try:
            log.info("NOT Sending mail message %d to %s about %s", it, ','.join(recipients), subject)
            #EmailMessage(subject, body, to=recipients).send(fail_silently=True)
            log.info("NOT Sent mail message %d")
        except ConnectionRefusedError as ex:
            log.error("Connection send mail message %d to %s", it, ','.join(recipients), exc_info=True)

    Thread(target=mail).run()  # this will come back to bite our butt, rest assured.


class Notifier:
    def __init__(self, subscription):
        assert isinstance(subscription, Subscription)
        self.s = subscription

    def _send(self, subject, *body):
        event = self.s.event
        subject = '%s - %s' % (subject, event.name)
        body = (self.s.badge + ',', '') + body + ('', '=' * len(event.name), event.name, event.url)
        _mail([self.s.email], subject, body)

    def can_pay(self):
        """This can happen in two cases, (1) esupa staff data verify accepted, or (2) the queue moved."""
        self._send('Pagamento Liberado',
                   'Sua inscrição está pronta para ser paga. Após o pagamento, ela será',
                   'confirmada, e sua vaga estará garantida.')<commit_msg>Made mail send async so that problematic mail settings won't lock up the response time.<commit_after># coding=utf-8
from logging import getLogger
from random import randint
from threading import Thread

from django.contrib.auth.models import User
from django.core.mail import EmailMessage
from django.core.urlresolvers import reverse

from .models import Subscription

log = getLogger(__name__)


def _mail(recipients, subject, body):
    it = 'mail#%d' % randint(0, 0x10000)
    def mail():
        try:
            log.info("Trying to send %s to %s about %s", it, ','.join(recipients), subject)
            EmailMessage(subject, body, to=recipients).send(fail_silently=True)
            log.info("Sent %s alright", it)
        except ConnectionRefusedError as ex:
            log.error("Connection failed for %s to %s", it, ','.join(recipients), exc_info=True)

    Thread(target=mail, name=it).start()  # this will come back to bite our butt, rest assured.


class Notifier:
    def __init__(self, subscription):
        assert isinstance(subscription, Subscription)
        self.s = subscription

    def _send(self, subject, *body):
        event = self.s.event
        subject = '%s - %s' % (subject, event.name)
        body = (self.s.badge + ',', '') + body + ('', '=' * len(event.name), event.name, event.url)
        _mail([self.s.email], subject, body)

    def can_pay(self):
        """This can happen in two cases, (1) esupa staff data verify accepted, or (2) the queue moved."""
        self._send('Pagamento Liberado',
                   'Sua inscrição está pronta para ser paga. Após o pagamento, ela será',
                   'confirmada, e sua vaga estará garantida.')
{'fraction_non_alphanumeric': 0.11713075060532688, 'fraction_numerical': 0.006053268765133172, 'mean_word_length': 2.972355769230769, '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': '1481077', 'n_tokens_mistral': 1005, 'n_tokens_neox': 968, 'n_words': 324}