Some DeviceProxy calls not releasing "GIL"?

I've noticed that some parts of the DeviceProxy API appear to block the interpreter even if run in a separate thread. Not sure what this means but my suspicion is that they hold the "Global Interpreter Lock", preventing the python interpreter from doing anything else meanwhile. Normally the calls are fast and therefore it's not very noticable, but e.g. if the device isn't responding, the whole application can be stuck, sometimes for seconds. Since these are basically just fetching data from a remote device, it seems it could release the GIL meanwhile.

The methods I've run into so far that behave like this (there might be more):

  • command_list_query()
  • attribute_list_query_ex()
  • description()

Here's a snippet I used in ipython, to try and investigate this. The idea is to run the call in a thread, and do something else while waiting for it to complete.

f = asyncio.ensure_future(asyncio.to_thread(d.description))
t0 = time.time()
while True:
    await asyncio.sleep(0.01)
    if f.done():
        try:
            f.result()
        except Exception as e:
            print(e)
            break
    print("***", time.time() - t0)

d is a DeviceProxy to a device that isn't running.

I would expect the while loop to run at least a few times before the call returns, but in my tests it instead seems to get stuck even before the loop has started, until the exception is raised. However if I instead put d.read_attribute, "status" in the to_thread call, it behaves as I expected (the while loop runs smoothly a number of times, then an exception raised.)

What do you think? Am I missing something?

(I also noticed that making proxy calls to non-running devices can sometimes fail quickly, and sometimes it takes several seconds to time out. No idea what causes this difference, but I guess it's not really related to pytango.)

Assignee Loading
Time tracking Loading