Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 836007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:54:47+00:00 2026-05-15T04:54:47+00:00

I am using gnosis.xml.pickle to convert an object of my own class to xml.

  • 0

I am using gnosis.xml.pickle to convert an object of my own class to xml. The object is initialized so that:

self.logger = MyLogger()

But when I do dump the object to a string I get an exception stating that the pickler encountered an unpickleable type (thread.lock).

Is there a way to ‘tag’ the logger attribute so that pickler will know not to try and pickle that attribute?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T04:54:48+00:00Added an answer on May 15, 2026 at 4:54 am

    You can define two methods, __getstate__ and __setstate__, to your class to override the default pickling behavior.

    http://docs.python.org/library/pickle.html#object.__getstate__

    __getstate__ should return a dict of attributes that you want to pickle.

    def __getstate__(self):
        d = dict(self.__dict__)
        del d['logger']
        return d
    

    __setstate__ should setup your object with the provided dict.

    def __setstate__(self, d):
        self.__dict__.update(d) # I *think* this is a safe way to do it
    

    Note that __init__ won’t be called when unpickling so you’ll have to create your logger in __setstate__

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using jQuery I'm trying to obtain the rotation state of an object but in
For a while I've been using a package called gnosis-utils which provides an XML
using Telerik.WinControls.Data; using Telerik.WinControls.UI.Export; namespace Directory { public partial class radForm : Form {
@using(Html.BeginForm(About, User, FormMethod.Post , new { id=aboutme})) { <fieldset> <ul> <li> <label class=block>About me</label>
Using NLTK and WordNet , how do I convert simple tense verb into its
using xmltextreader, how would I load a hashtable. XML: <base><user name=john>2342343</user><user name=mark>239099393</user></base> This was
Using C# How can I show a document in richtextbox without scrollbars, But I
Ok so you know how Gnosis released gizmodo's passwords then said that their password
Using SSRS 2008 R2 I have a background process that dynamically generates RDL for
Using server-side C#, how can I convert a querystring to a JSON string of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.