Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

WIP: Usubscribe from events in worker thread (PyTango#292) #1093

Closed

Conversation

reszelaz
Copy link

Similarly to #1091, this PR tries to workaround PyTango#292.
This one implements the 3.b option proposed by @schooft in tango-controls/pytango#292 (comment). Thanks!

I tried this PR with sardana-org/sardana#1312 ( which reverts the Sardana workaround and use zombie concept in tests) and it worked for 7 testsuite executions already. Note that the usage of zombie API in tests most probably won't be need if we implement #1092.

Workaround PyTango#292 and delegate unsubscribe to a worker thread.
It is not sure if this flag is necessary. In principle if the cleanUp was called it means that TangoAttribute
is already being destructed so there should be no events coming. But events come in another thread (Tango)...
@cpascual
Copy link
Member

cpascual commented Mar 20, 2020

This is making 2 tests to fail:

  • test_cleanup_after_polling
  • test_cleanup_state_after_polling

@reszelaz
Copy link
Author

This is making 2 tests to fail:

  • test_cleanup_after_polling
  • test_cleanup_state_after_polling

These most probably fail cause I commented the disabling of polling in TangoAttribute._finalUnsubscribeChangeEvents which was not clear to me that it had to be done exactly there. Why not in TangoAttribute.cleanUp?

@reszelaz
Copy link
Author

Anyway I have tested it with a typical macro which discovered PyTango#292:

import taurus
from sardana.macroserver.macro import macro


@macro()
def test_dev_gc(self):
    pool = self.door.get_pools()[0]
    moveables = []
    moveables.extend(pool.getElementNamesOfType("motor"))
    moveables.extend(pool.getElementNamesOfType("pseudomotor"))
    channels = []
    channels.extend(pool.getElementNamesOfType("ctexpchannel"))
    channels.extend(pool.getElementNamesOfType("zerodexpchannel"))
    channels.extend(pool.getElementNamesOfType("onedexpchannel"))
    for m in moveables:
        self.print("{}: {}".format(m, taurus.Device(m).getPosition()))
    for ch in channels:
        self.print("{}: {}".format(ch, taurus.Device(ch).getValue()))

And this fails. So 7 consecutive executions of the sardanatestsuite is not an indicator that this workaround works. The above macro is a better way to check it.

So, while executing the macro, the MacroServer hanged with: work_th_bt.txt and work_th_py-bt.txt.

@reszelaz
Copy link
Author

reszelaz commented May 7, 2020

The root issue was solved in tango-controls/cppTango#699.
It is available starting from cppTango 9.3.4rc5. Hence I do not foresee to work anymore on this PR.

@reszelaz reszelaz closed this May 7, 2020
@cpascual cpascual modified the milestones: Jan20, Jul20 May 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants