pcdshub / pmps-ui

User interfaces and diagnostics for PMPS
Other
0 stars 8 forks source link

MAINT: remove some partials that give terminal spam on pcds-5.8.0 #94

Closed ZLLentz closed 10 months ago

ZLLentz commented 11 months ago

There is a new conda environment on the way. Details here: https://github.com/pcdshub/pcds-envs/pull/302

When running with this conda env, you get crazy error spam of pmps-ui (and some other apps) at close:

[2023-10-10 16:30:36,228] [ERROR   ] - Unable to remove connection for <PyDMChannel (ca://PMPS:KFE:Arbiter:01:AP:Entry:002:PhotonEnergyRanges_RBV)>
Traceback (most recent call last):
  File "/cds/home/z/zlentz/github/pydm/pydm/widgets/channel.py", line 164, in disconnect
    plugin.remove_connection(self, destroying=destroying)
  File "/cds/home/z/zlentz/github/pydm/pydm/data_plugins/plugin.py", line 317, in remove_connection
    self.connections[connection_id].remove_listener(channel, destroying=destroying)
  File "/cds/home/z/zlentz/github/pydm/pydm/data_plugins/plugin.py", line 118, in remove_listener
    self.connection_state_signal.disconnect(channel.connection_slot)
RuntimeError: wrapped C/C++ object of type Connection has been deleted

Further investigation led me to realize this issue was cropping up for:

I removed the partials here, as was already known to be correct practice, and the issues went away.

There are more partials in the application but I don't feel strongly about taking care of them today, since they aren't causing immediate issues.

I'm not really sure what's going on or if this is even the best/correct fix. My partial fix is basically "use a method instead of a partial" and "use a function within the method closure instead of a partial", rather than refactoring to individual QObjects or using the WeakPartialSlot mechanisms.

This also fixes an issue where we were calling a list as a function in the channels function, which exists mainly for compatibility with how PyDM finds channels to clean up. Since this code snippit clearly never was run in previous iterations, I can only conclude that qt cleanup works slightly differently in 5.15 than it did in 5.12.

ZLLentz commented 11 months ago

This works on pcds-5.8.0 and doesn't break pcds-5.6.0, which is the version pmps-ui is currently frozen at in prod (dev)

ZLLentz commented 11 months ago

This is actually not enough- I'm not sure if it's a race condition or what, but I still have some of these error logs and not others. I don't really want to import other packages here to keep this portable for ACR, so I might find a simpler approach that deals with the symptoms.

ZLLentz commented 10 months ago

96 has a better solution to this