'Validate that the connection isn\'t accessed by another thread than the
one which originally created it, unless the connection was explicitly
authorized to be shared between threads (via the `allow_thread_sharing`
property). Raise an exception if the validation fails.'

def validate_thread_sharing(self):

    if (not (self.allow_thread_sharing or (self._thread_ident == _thread.get_ident()))):
        raise DatabaseError(("DatabaseWrapper    objects    created    in    a    thread    can    only    be    used    in    that    same    thread.    The    object    with    alias    '%s'    was    created    in    thread    id    %s    and    this    is    thread    id    %s." % (self.alias, self._thread_ident, _thread.get_ident())))
