async-class icon indicating copy to clipboard operation
async-class copied to clipboard

__adel__ destructor not called automatically

Open mixa2130 opened this issue 4 years ago • 4 comments

Hello, hope you had a good day. I think it will be a good idea - to add self-calling class destructor

class Strava(AsyncClass):
    async def __ainit__(self, login, password) -> NoReturn:
        self._session = aiohttp.ClientSession()

    async def __adel__(self) -> None:
        print('hello from async del')
        # await self._session.close()

    def __del__(self):
        print('hello from del')

Output: hello from del

As you can see - now __adel__ doesn't execute - it works only through close method, which is redundant for many developers

mixa2130 avatar Apr 18 '21 21:04 mixa2130

that's because you redeclare del method from here

mosquito avatar Apr 20 '21 10:04 mosquito

Okay, that's an example without redeclare:

Screenshot_20210420_155820

mixa2130 avatar Apr 20 '21 13:04 mixa2130

Yes, the __adel__ method was the reason I wanted to use this lib, it's a pity it's not called automatically :-(.

tdivis avatar Oct 18 '22 14:10 tdivis

@tdivis @mixa2130, this is a very experimental project, if you know what the problem is, feel free to write, I will try to investigate it, but I don't know if I can fix it in my free time or not.

mosquito avatar Oct 18 '22 15:10 mosquito