RE: Logging in __del__()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert Rawlins

    RE: Logging in __del__()

    Hi Fredrik,
    When the application is running, or when it is shutting down?
    This is interesting, I did a test where I explicitly destroyed the instance
    using 'del my_instance' while the application was running and no error was
    thrown.

    It would see you are right, when the application ends it kills the logging
    module before my classes. I think you're on the right approach just
    try/except it and leave it be.

    Am I right in thinking that Python destroys instances of classes when it
    deems they are no longer needed? I shouldn't have to explicitly delete the
    classes, right?

    Thanks Fredrik,

    Robert

  • Vinay Sajip

    #2
    Re: Logging in __del__()

    On Jul 15, 1:51 pm, "Robert Rawlins"
    <robert.rawl... @thinkbluemedia .co.ukwrote:
    >
    Am I right in thinking that Python destroys instances of classes when it
    deems they are no longer needed? I shouldn't have to explicitly delete the
    classes, right?
    Python uses reference counting with a cycle detector, but the
    detector's behaviour is different if there are finalizers (__del__) -
    see

    The official home of the Python Programming Language


    Regards,

    Vinay Sajip

    Comment

    • Robert Rawlins

      #3
      RE: Logging in __del__()

      Hi Vinay,
      Python uses reference counting with a cycle detector, but the
      detector's behaviour is different if there are finalizers (__del__) -
      see
      >
      The official home of the Python Programming Language

      >
      Thank you for the link, that certainly explains a great deal.

      So, am I right to assume that python will still handle its garbage disposal
      if I implement __del__(), it just handles circular references in a slightly
      different way, but to the same effect. Right?

      Cheers,

      Robert

      Comment

      • Marc 'BlackJack' Rintsch

        #4
        Re: Logging in __del__()

        On Wed, 16 Jul 2008 12:38:50 +0100, Robert Rawlins wrote:
        So, am I right to assume that python will still handle its garbage disposal
        if I implement __del__(), it just handles circular references in a slightly
        different way, but to the same effect. Right?
        No. Circular references in objects with a `__del__()` implementation are
        not collected! Why are you using `__del__()` anyway? Are you aware of
        the promises that are *not* made! It's not guaranteed when the method
        is called nor if it is called at all!

        Ciao,
        Marc 'BlackJack' Rintsch

        Comment

        Working...