UnhashableTypeError: Cannot hash object of type _thread.RLock, found in the arguments of establish_connection()

Hi. I am rewriting an old program and i wanted to redefine some functions also. I created a new class and copied the exact same method as before in the new class but now it doesnt work… I allways recieve the mentioned error.
The function is the following:

@st.cache(allow_output_mutation=True)

def establish_connection(self):

    auth_provider = PlainTextAuthProvider(username='example', password='example')

    cluster = Cluster(auth_provider=auth_provider,

                      contact_points=['just omitting them'])

    session = cluster.connect()

    self.print_information("Information", "Cassandra Database successfully connected")

    return session

Does sombody now why the code works in a class but in another one new doesnt?