def _work(self, backend, package, ident='', log=True):
        """
        Centralized task worker code. Used internally, see send_signal() and 
        work() for the external interfaces.
        """
        num = self._sending_task(backend)
        if log:
            self.log(INFO, 'Starting %s backend task #%s (%s)' % 
                           (backend, num, ident))
        try:
            conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            conn.connect(backend)
            self.send(conn, package)
            result = self.recv(conn)
            self.log(DEBUG, result)
            result = self.codec.decode(result)
        except Exception as e:
            self._canceling_task(backend)
            raise
        else:
            self._closing_task(backend)
            if log:
                self.log(INFO, 'Finished %s backend task #%s (%s)' % 
                               (backend, num, ident))
        finally:
            conn.close()
        
        if result[0] == 'error':
            # We reraise errors in our own way.
            raise BackendProcessingError(*result[1:])
        else:
            return result[1]
Centralized task worker code. Used internally, see send_signal() and 
        work() for the external interfaces.