[PEAK] setuptools: Test works only after second invocation

P.J. Eby pje at telecommunity.com
Thu Apr 29 17:19:54 EDT 2010


At 03:38 PM 4/29/2010 -0400, Nikolaus Rath wrote:
>On 04/29/2010 02:36 PM, P.J. Eby wrote:
> > At 12:34 PM 4/29/2010 -0400, Nikolaus Rath wrote:
> >> Is setuptools by any chance doing more of this kind of black magic?
> >
> > Sure, lots.  ;-)
> >
> >> I'm about to start debugging a second, even more mysterious looking
> >> problem when running the test command. If it is used in combination
> >> with Psyco, I get exceptions after all the tests have completed:
> >
> > These exceptions are happening at Python shutdown.  You can tell by this
> > bit:
> >
> >>     return embedframe(_psyco.getframe(depth+1))
> >> AttributeError: 'NoneType' object has no attribute 'getframe'
> >
> > _psyco is obviously 'None' here -- which would only happen during the
> > Python shutdown phase where the interpreter sets *all* module globals to
> > None.  So the problem is that your excepthook implementation is running
> > during that phase.  It probably doesn't have anything to do with
> > setuptools, but you'll need to change your code to work correctly at
> > shutdown time in order to find out what the real error(s) are.
>
>Actually I don't provide my own sys.excepthook implemention. But I 
>think Ubuntu's apport may be messing with this, so I explicitly 
>reset it to sys.__excepthook__ now.
>
>This is the error message that I get: (note that it only happens if 
>the test is run by setuptools *and* if Psyco is enabled. If the test 
>is run directly, or if Psyco is not enabled, everything works fine):
>
>Ran 1 test in 4.193s
>
>OK
>Exception TypeError: "'NoneType' object is not callable" in <frame 
>object at 0x8ecb9fc> ignored
>Exception TypeError: "'NoneType' object is not callable" in <frame 
>object at 0x8ecb9fc> ignored
>Error in atexit._run_exitfuncs:
>Traceback (most recent call last):
>   File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
>     func(*targs, **kargs)
>   File "/usr/lib/python2.6/dist-packages/psyco/profiler.py", line 38, in go
>     go_lock.acquire()
>AttributeError: 'NoneType' object has no attribute 'acquire'
>Error in sys.exitfunc:
>Traceback (most recent call last):
>   File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
>     func(*targs, **kargs)
>   File "/usr/lib/python2.6/dist-packages/psyco/profiler.py", line 38, in go
>     go_lock.acquire()
>AttributeError: 'NoneType' object has no attribute 'acquire'
>[0] inspiron:~/projekte/s3ql$

Well, it's still a shutdown-time issue - presumably go_lock is being 
set to None before this point.  However, if the only part of 
setuptools you're using is the test command, and it's not installing 
anything from source (and thereby using the sandbox), it's unlikely 
to be a direct result of setuptools.

You might try putting a call to garbage collect before your test 
exits, not to mention narrowing down the scope of the test(s) to see 
more detail about what has to happen for the exception to occur.



More information about the PEAK mailing list