By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,772 Members | 906 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,772 IT Pros & Developers. It's quick & easy.

imported method from module evaluates to None in some cases

P: n/a

Hi:

I'm having a problem in some zope (2.10) code (HTTPResponse.py) 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_getstacksize() 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._request),
'%s %s' % (self._request.reply_code, self._bytes))
if not self._channel.closed:
self._channel.push(LoggingProducer(self._request,
self._bytes), 0)
self._channel.push(CallbackProducer(self._channel. done),
0)
self._channel.push(CallbackProducer(
lambda t=('E', id(self._request)): apply
(DebugLogger.log, t)), 0)
if self._shutdown:
self._channel.push(ShutdownProducer(), 0)
Wakeup()
else:
if self._close: self._channel.push(None, 0)
Wakeup() # TypeError IS RAISED HERE
else:
# channel closed too soon

self._request.log(self._bytes)
DebugLogger.log('E', id(self._request))

if self._shutdown:
Wakeup(lambda: asyncore.close_all())
else:
Wakeup()

self._channel=None #need to break cycles?
self._request=None
Nov 20 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Andrew <an************@gmail.comwrites:
I'm having a problem in some zope (2.10) code (HTTPResponse.py) 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.
Nov 20 '08 #2

P: n/a
On Nov 20, 6:53 am, Hrvoje Niksic <hnik...@xemacs.orgwrote:
Andrew <andrewpadil...@gmail.comwrites:
I'm having a problem in some zope (2.10) code (HTTPResponse.py) 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?

Nov 20 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.