Python exception

Hi!

Any idea where this exception can come from?

Exception exceptions.ReferenceError: ‘weakly-referenced object no longer
exists’ in <bound method db_flexrf_2400_tx_mimo_b.del of
<gnuradio.db_flexrf_mimo.db_flexrf_2400_tx_mimo_b object at 0x8895c2c>>
ignored

The code does not explicitly delete the subdevice. I instantiate the
usrp object, then I retrieve a handle to the subdev to set gain etc.
Handles to usrp and subdev are stored in class members. The object
holding these handles is not destroyed before program end.

Greetings
Dominik

Dominik A. wrote:

Exception exceptions.ReferenceError: ‘weakly-referenced object no longer
exists’ in <bound method db_flexrf_2400_tx_mimo_b.del of
<gnuradio.db_flexrf_mimo.db_flexrf_2400_tx_mimo_b object at 0x8895c2c>>
ignored

The subdev object internally holds a weak reference to the USRP object
(this avoids a circular dependency.)

When your class goes out of scope at the end of your application, Python
deletes all of the class members and then the class itself. In this
case, what is happening is that Python deletes the USRP object, and then
when it deletes the subdev, the weak reference points to nothing, hence
the error.

While it’s harmless, to avoid the error message, I put in an explicit
call to delete the subdev object inside the del method of the
enclosing class. That way, the subdev object is forced to be deleted
before Python deletes the USRP object:

class foo:
def del(self):
del self.subdev

(adjust for your class and member names)


Johnathan C.
Corgan Enterprises LLC
http://corganenterprises.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs