def test_send_async_catches_error(self): """send_async should capture sending exceptions properly.""" backends = {'backend': {'ENGINE': harness.RaisesBackend}} with override_settings(INSTALLED_BACKENDS=backends): try: send_async("backend", "1234", "hello", ["1112223333"], {}) except: self.fail("Sending exceptions should be caught within task")
def backend_preparation(self, msg): """Queue outbound message to be processed in the background.""" context = msg.extra_backend_context() grouped_identities = self.group_outgoing_identities(msg) for backend_name, identities in grouped_identities.items(): eager = self.is_eager(backend_name) if eager: logger.debug('Executing in current process') send_async(backend_name, msg.id, msg.text, identities, context) else: logger.debug('Executing asynchronously') send_async.delay(backend_name, msg.id, msg.text, identities, context)
def backend_preparation(self, msg): """Queue outbound message to be processed in the background.""" context = msg.extra_backend_context() grouped_identities = self.group_outgoing_identities(msg) for backend_name, identities in grouped_identities.iteritems(): eager = self.is_eager(backend_name) if eager: logger.debug('Executing in current process') send_async(backend_name, msg.id, msg.text, identities, context) else: logger.debug('Executing asynchronously') send_async.delay(backend_name, msg.id, msg.text, identities, context)