tiqi-group / pydase

A Python library for creating remote control interfaces of Python objects.
https://pydase.readthedocs.io
MIT License
2 stars 1 forks source link

Protected lists crash pydase #29

Closed mosmuell closed 1 year ago

mosmuell commented 1 year ago

When creating a protected list attribute, the web interface crashes:

import asyncio

import pydase

class MyService(pydase.DataService):
    _protected_list = [0, 1]

    async def update(self) -> None:
        while True:
            self._protected_list[0] += 1
            self._protected_list[1] += 1
            await asyncio.sleep(1)

if __name__ == "__main__":
    service = MyService()
    print(MyService().serialize())
    pydase.Server(service).run()

This is because lists are always converted to DataServiceLists. To change this, skipping a list attribute that starts with an underscore should do the job.

image

mosmuell commented 1 year ago

As this block registers a callback on DataServiceList instances used in property source code, I will still cast all protected lists into DataServiceLists. Otherwise, properties depending on protected lists will not be updated when the protected lists changed. What I will do instead of ignoring protected lists is to not pass it a callback to emit a notification when it changed.