NameError: global name 'PyDeadObjectError' is not defined

In another thread I ranted a bit about having to use a try...except to
sidestep the PyDeadObjectError I get often when using pubsub. But now
I'm pretty confused as to even how to do that, because I am using this
to except the error:

try:
    Publisher().unsubscribe(self.__onReceiveMessage, 'Show popup')
    self.Show()
except PyDeadObjectError:
    pass

and I am now getting this *other* error:

NameError: global name 'PyDeadObjectError' is not defined

What am I doing wrong? After getting 50+ PyDeadObjectErrors in the
last few times I've done wxPython, I'm sort of bleary-eyed about it.

Thanks,
Che

Hi,

···

On Mar 4, 2010, at 10:44 PM, C M wrote:

In another thread I ranted a bit about having to use a try...except to
sidestep the PyDeadObjectError I get often when using pubsub. But now
I'm pretty confused as to even how to do that, because I am using this
to except the error:

try:
   Publisher().unsubscribe(self.__onReceiveMessage, 'Show popup')
   self.Show()
except PyDeadObjectError:
   pass

and I am now getting this *other* error:

NameError: global name 'PyDeadObjectError' is not defined

What am I doing wrong? After getting 50+ PyDeadObjectErrors in the
last few times I've done wxPython, I'm sort of bleary-eyed about it.

The PyDeadObject error is an exception generated by wxPython it is not a standard python exception type.

see: wx.PyDeadObjectError

Also, not sure why your wrapping it around your unsubscribe call in the snippet above?

Cody

Hi,

In another thread I ranted a bit about having to use a try...except to
sidestep the PyDeadObjectError I get often when using pubsub. But now
I'm pretty confused as to even how to do that, because I am using this
to except the error:

try:
Publisher().unsubscribe(self.__onReceiveMessage, 'Show popup')
self.Show()
except PyDeadObjectError:
pass

and I am now getting this *other* error:

NameError: global name 'PyDeadObjectError' is not defined

What am I doing wrong? After getting 50+ PyDeadObjectErrors in the
last few times I've done wxPython, I'm sort of bleary-eyed about it.

The PyDeadObject error is an exception generated by wxPython it is not a
standard python exception type.

see: wx.PyDeadObjectError

Then how is it excepted? Will excepting AttributeError pick it up?
(Haven't had time to test that tonight yet...I'm not even sure yet of
a good test situation to get it to throw the error).

I've seen Werner except PyDeadObjectError for pubsub use in examples
on this list, and I thought it was working for me, so I was surprised
when I got this NameError. Werner, any insights?

Also, not sure why your wrapping it around your unsubscribe call in the
snippet above?

Probably a desperate attempt to stop these errors: when unsubscribing
didn't work and then excepting didn't work, I sort of put the two
together. Flailing, I know. :smiley:

Che

···

On Thu, Mar 4, 2010 at 11:48 PM, Cody Precord <codyprecord@gmail.com> wrote:

On Mar 4, 2010, at 10:44 PM, C M wrote:

Hi,

Then how is it excepted? Will excepting AttributeError pick it up?
(Haven't had time to test that tonight yet...I'm not even sure yet of
a good test situation to get it to throw the error).

I've seen Werner except PyDeadObjectError for pubsub use in examples
on this list, and I thought it was working for me, so I was surprised
when I got this NameError. Werner, any insights?

No, it is not in the global namespace is why your getting the error....

try:
     something()
except wx.PyDeadObjectError:
     doSomethingElse()

Also, not sure why your wrapping it around your unsubscribe call in the
snippet above?

Probably a desperate attempt to stop these errors: when unsubscribing
didn't work and then excepting didn't work, I sort of put the two
together. Flailing, I know. :smiley:

Your getting the errors when your calling sendmessage somewhere else in the program. You need to look at how your managing the lifetime of the objects to fix the problem your having properly, or when that fails you need to check in your message handler for the exception.

Without knowing anything about your program or the flow of events I can't tell you much more than go through the flow of what is happening in your program (draw some diagrams if it helps) and find where you mismanaging things.

Cody

···

On Mar 4, 2010, at 11:23 PM, C M wrote:

Hi, Cody.

I've seen Werner except PyDeadObjectError for pubsub use in examples
on this list, and I thought it was working for me, so I was surprised
when I got this NameError. Werner, any insights?

No, it is not in the global namespace is why your getting the error....

try:
something()
except wx.PyDeadObjectError:
doSomethingElse()

Ah, I thought the import wx would take care of that, but OK.

Without knowing anything about your program or the flow of events I can't
tell you much more than go through the flow of what is happening in your
program (draw some diagrams if it helps) and find where you mismanaging
things.

I'll get to it! Thanks,
Che