that' not very useful errorbut it looks like we're trying to pickle something we shouldn' be that would be the timer instancewe're storing reference to self timer in the schedule methodand that attribute cannot be serialized when pickle tries to serialize an objectit simply tries to store the object' __dict__ attribute__dict__ is dictionary mapping all the attribute names on the object to their values luckilybefore checking __dict__pickle checks to see whether __getstate__ method exists if it doesit will store the return value of that method instead of the __dict__ let' add __getstate__ method to our updatedurl class that simply returns copy of the __dict__ without timerdef __getstate__(self)new_state self __dict__ copy(if 'timerin new_statedel new_state['timer'return new_state if we pickle the object nowit will no longer fail and we can even successfully restore that object using loads howeverthe restored object doesn' have timer attributeso it will not be refreshing the content like it is designed to do we need to somehow create new timer (to replace the missing onewhen the object is unpickled as we might expectthere is complementary __setstate__ method that can be implemented to customize unpickling this method accepts single argumentwhich is the object returned by __getstate__ if we implement both methods__ getstate__ is not required to return dictionarysince __setstate__ will know what to do with whatever object __getstate__ chooses to return in our casewe simply want to restore the __dict__and then create new timerdef __setstate__(selfdata)self __dict__ data self schedule(the pickle module is very flexible and provides other tools to further customize the pickling process if you need them howeverthese are beyond the scope of this book the tools we've covered are sufficient for many basic pickling tasks objects to be pickled are normally relatively simple data objectswe would not likely pickle an entire running program or complicated design patternfor example