imported method from module evaluates to None in some cases

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

    imported method from module evaluates to None in some cases


    Hi:

    I'm having a problem in some zope (2.10) code (HTTPResponse.p y) where
    a method that gets imported somehow evaluates to None in certain cases
    which causes a TypeError exception to be raised (eg: TypeError:
    'NoneType' object is not callable). The code excerpt is below where
    the exception is raised on the line with the comment 'TypeError IS
    RAISED HERE'. I've read that the thread stack size may be insufficient
    but the I compiled a test pthreads program on the same system to get
    the default. I used pthread_attr_ge tstacksize() and it returned
    3657952 (3.5 mb?). I would imagine that's enough. Any ideas how this
    could occur?

    from PubCore.ZEvent import Wakeup

    def close(self):
    DebugLogger.log ('A', id(self._reques t),
    '%s %s' % (self._request. reply_code, self._bytes))
    if not self._channel.c losed:
    self._channel.p ush(LoggingProd ucer(self._requ est,
    self._bytes), 0)
    self._channel.p ush(CallbackPro ducer(self._cha nnel.done),
    0)
    self._channel.p ush(CallbackPro ducer(
    lambda t=('E', id(self._reques t)): apply
    (DebugLogger.lo g, t)), 0)
    if self._shutdown:
    self._channel.p ush(ShutdownPro ducer(), 0)
    Wakeup()
    else:
    if self._close: self._channel.p ush(None, 0)
    Wakeup() # TypeError IS RAISED HERE
    else:
    # channel closed too soon

    self._request.l og(self._bytes)
    DebugLogger.log ('E', id(self._reques t))

    if self._shutdown:
    Wakeup(lambda: asyncore.close_ all())
    else:
    Wakeup()

    self._channel=N one #need to break cycles?
    self._request=N one


  • Hrvoje Niksic

    #2
    Re: imported method from module evaluates to None in some cases

    Andrew <andrewpadilla1 @gmail.comwrite s:
    I'm having a problem in some zope (2.10) code (HTTPResponse.p y) where
    a method that gets imported somehow evaluates to None in certain cases
    which causes a TypeError exception to be raised (eg: TypeError:
    'NoneType' object is not callable). The code excerpt is below where
    the exception is raised on the line with the comment 'TypeError IS
    RAISED HERE'.
    Could the "certain cases" involve automatic invocation of the close
    method at interpreter shutdown? While the interpreter shuts down,
    module-level variables are set to None. This is documented in some
    detail in http://www.python.org/doc/essays/cleanup/, steps C1-C3.

    Comment

    • Andrew

      #3
      Re: imported method from module evaluates to None in some cases

      On Nov 20, 6:53 am, Hrvoje Niksic <hnik...@xemacs .orgwrote:
      Andrew <andrewpadil... @gmail.comwrite s:
      I'm having a problem in some zope (2.10) code (HTTPResponse.p y) where
      a method that gets imported somehow evaluates to None in certain cases
      which causes a TypeError exception to be raised (eg: TypeError:
      'NoneType' object is not callable). The code excerpt is below where
      the exception is raised on the line with the comment 'TypeError IS
      RAISED HERE'.
      >
      Could the "certain cases" involve automatic invocation of the close
      method at interpreter shutdown? While the interpreter shuts down,
      module-level variables are set to None. This is documented in some
      detail inhttp://www.python.org/doc/essays/cleanup/, steps C1-C3.
      That's possible. I didn't know that. Now I guess the question for me
      is why and where did the interpreter shutdown? I don't see log entries
      relating to it. Is it possible for me to intercept an interpreter
      shutdown so I can find out the location and possibly the reason why
      the interpreter abruptly shuts down?

      Comment

      Working...