python 2.3.2 hangs when returning an int

Discussion in 'Python' started by omission9, Feb 23, 2004.

  1. omission9

    omission9 Guest

    Any advice on the following would be much appreciated. I have thrown
    everything I have at it and am completely stumped. I apologize for the
    length, I have tried to be as succint as possible.

    I have a pythoncard/wxPython application. The application works well
    except that users were reporting occasional crashes. The application
    would simply stop and just hang. I was able to reproduce the bug
    faithfully and ran the application in the python debugger pdb.py.
    The trace is below and I simply cannot understand why it is hanging
    where it is. The application gets stuck executing

    return len(self.data[0])

    which is in this function

    def GetNumberCols(self):
    if len(self.data) <= 0:
    return 0
    else:
    return len(self.data[0])

    This works many many times during the applications execution, indeed
    several successful runs of this line are visible immediatley above the
    hang. I have also printed out the value of self.data. This is a list
    containing 12 inner lists each of length 3 at the point of the hang and
    is never larger than that.
    What on earth could cause this to stop the interpreter cold in its
    tracks without an exception being thrown? CPU usage on the machine is
    high throughout the application's execution and stays as such after the
    "hang" begins. I eventually kill the app although I have let it run for
    a long time and it never leaves this line.
    For what its worth, I am using python 2.3.2 on windows2k.

    Anyone have idea what could be happening?

    c:\python23\lib\site-packages\wxpython\grid.py(664)_setOORInfo()->None
    -> return val
    (Pdb) s
    --Return--
    c:\python23\lib\site-packages\wxpython\grid.py(850)__init__()->None
    -> self._setOORInfo(self)
    (Pdb) s


    c:\cygwin\home\ar881\development\bt_analysis\console\ndbbtable.py(17)__init

    __()
    -> self.data = data
    (Pdb) s


    c:\cygwin\home\ar881\development\bt_analysis\console\ndbbtable.py(18)__init

    __()
    -> self.colLabels = headings
    (Pdb) s
     
    omission9, Feb 23, 2004
    #1
    1. Advertising

  2. (omission9) writes:

    > Any advice on the following would be much appreciated. I have thrown
    > everything I have at it and am completely stumped. I apologize for the
    > length, I have tried to be as succint as possible.
    >
    > I have a pythoncard/wxPython application. The application works well
    > except that users were reporting occasional crashes. The application
    > would simply stop and just hang. I was able to reproduce the bug
    > faithfully and ran the application in the python debugger pdb.py.
    > The trace is below and I simply cannot understand why it is hanging
    > where it is. The application gets stuck executing
    >
    > return len(self.data[0])


    Does pythoncard or wxPython (or your program) use weak references?
    There have been serious bugs fixed with weakrefs in Python 2.3.3.

    Thomas
     
    Thomas Heller, Feb 23, 2004
    #2
    1. Advertising

  3. omission9

    Ziaran Guest

    I guess it is a thread synchronization progblem
    In that case some other thread modifies self.data leaving it empty in the
    time between the if statement expression is evalutaed and the time the
    return statement is executed.

    Can this be the case?

    "omission9" <> wrote in message
    news:...
    > Any advice on the following would be much appreciated. I have thrown
    > everything I have at it and am completely stumped. I apologize for the
    > length, I have tried to be as succint as possible.
    >
    > I have a pythoncard/wxPython application. The application works well
    > except that users were reporting occasional crashes. The application
    > would simply stop and just hang. I was able to reproduce the bug
    > faithfully and ran the application in the python debugger pdb.py.
    > The trace is below and I simply cannot understand why it is hanging
    > where it is. The application gets stuck executing
    >
    > return len(self.data[0])
    >
    > which is in this function
    >
    > def GetNumberCols(self):
    > if len(self.data) <= 0:
    > return 0
    > else:
    > return len(self.data[0])
    >
    > This works many many times during the applications execution, indeed
    > several successful runs of this line are visible immediatley above the
    > hang. I have also printed out the value of self.data. This is a list
    > containing 12 inner lists each of length 3 at the point of the hang and
    > is never larger than that.
    > What on earth could cause this to stop the interpreter cold in its
    > tracks without an exception being thrown? CPU usage on the machine is
    > high throughout the application's execution and stays as such after the
    > "hang" begins. I eventually kill the app although I have let it run for
    > a long time and it never leaves this line.
    > For what its worth, I am using python 2.3.2 on windows2k.
    >
    > Anyone have idea what could be happening?
    >
    > c:\python23\lib\site-packages\wxpython\grid.py(664)_setOORInfo()->None
    > -> return val
    > (Pdb) s
    > --Return--
    > c:\python23\lib\site-packages\wxpython\grid.py(850)__init__()->None
    > -> self._setOORInfo(self)
    > (Pdb) s
    >
    >
    >

    c:\cygwin\home\ar881\development\bt_analysis\console\ndbbtable.py(17)__init
    >
    > __()
    > -> self.data = data
    > (Pdb) s
    >
    >
    >

    c:\cygwin\home\ar881\development\bt_analysis\console\ndbbtable.py(18)__init
    >
    > __()
    > -> self.colLabels = headings
    > (Pdb) s
     
    Ziaran, Feb 23, 2004
    #3
  4. omission9

    omission9 Guest

    Thanks to all who responded. This took me forever to replicate and is
    not that easy to demonstrate outside of my fairly complex application.
    Basically, I feel that this is the fault of the Python garbage
    collector. What was happening was that in one function I locally defined
    a class which extended wxGrid. In another function, which was called by
    the first one mentioned, I instantiated another instance, local to the
    function, of that class. It seems that even though the wxGrid class
    used in the calling function was only used after the function call
    some stray references or something to the other instance were still
    drifting around in the interpreter which were causing some bizarro
    problems like the one in my original post. By eliminating the instance
    in the function that was being called I eliminated the problem.
    BIZARRE!! What made this so awful was that it took many many iterations
    of these functions to generate the error. I have no idea why it didn't
    blow the first, say, hundred times through.
    Maybe if I ever get the motivation I'll attach a C debugger to the whole
    thing and look deeper into the guts.


    omission9 wrote:

    > Any advice on the following would be much appreciated. I have thrown
    > everything I have at it and am completely stumped. I apologize for the
    > length, I have tried to be as succint as possible.
    >
    > I have a pythoncard/wxPython application. The application works well
    > except that users were reporting occasional crashes. The application
    > would simply stop and just hang. I was able to reproduce the bug
    > faithfully and ran the application in the python debugger pdb.py.
    > The trace is below and I simply cannot understand why it is hanging
    > where it is. The application gets stuck executing
    >
    > return len(self.data[0])
    >
    > which is in this function
    >
    > def GetNumberCols(self):
    > if len(self.data) <= 0:
    > return 0
    > else:
    > return len(self.data[0])
    >
    > This works many many times during the applications execution, indeed
    > several successful runs of this line are visible immediatley above the
    > hang. I have also printed out the value of self.data. This is a list
    > containing 12 inner lists each of length 3 at the point of the hang and
    > is never larger than that.
    > What on earth could cause this to stop the interpreter cold in its
    > tracks without an exception being thrown? CPU usage on the machine is
    > high throughout the application's execution and stays as such after the
    > "hang" begins. I eventually kill the app although I have let it run for
    > a long time and it never leaves this line.
    > For what its worth, I am using python 2.3.2 on windows2k.
    >
    > Anyone have idea what could be happening?
    >
    > c:\python23\lib\site-packages\wxpython\grid.py(664)_setOORInfo()->None
    > -> return val
    > (Pdb) s
    > --Return--
    > c:\python23\lib\site-packages\wxpython\grid.py(850)__init__()->None
    > -> self._setOORInfo(self)
    > (Pdb) s
    >
    >
    > c:\cygwin\home\ar881\development\bt_analysis\console\ndbbtable.py(17)__init
    >
    > __()
    > -> self.data = data
    > (Pdb) s
    >
    >
    > c:\cygwin\home\ar881\development\bt_analysis\console\ndbbtable.py(18)__init
    >
    > __()
    > -> self.colLabels = headings
    > (Pdb) s
     
    omission9, Feb 25, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Schnoffos
    Replies:
    2
    Views:
    1,223
    Martien Verbruggen
    Jun 27, 2003
  2. Hal Styli
    Replies:
    14
    Views:
    1,650
    Old Wolf
    Jan 20, 2004
  3. arun
    Replies:
    8
    Views:
    460
    Dave Thompson
    Jul 31, 2006
  4. aling
    Replies:
    8
    Views:
    958
    Jim Langston
    Oct 20, 2005
  5. Replies:
    9
    Views:
    436
    James Kanze
    Apr 17, 2007
Loading...

Share This Page