ionelmc / python-lazy-object-proxy

A fast and thorough lazy object proxy.
BSD 2-Clause "Simplified" License
247 stars 36 forks source link

Support `async with` and other asyncio-specific object methods #49

Closed garyd203 closed 3 years ago

garyd203 commented 3 years ago

Is it possible to add proxy hooks to wrap the special methods used by async with and other asyncio-specific syntax?

ionelmc commented 3 years ago

Yes, will add them.

ionelmc commented 3 years ago

I hope you'll help with beta-testing this cause I'm pretty sure I won't be able to figure out all the corner cases from the first try :-)

garyd203 commented 3 years ago

Absolutely! I don't have very sophisticated needs myself, but certainly happy to give a beta version a run - just let me know when and how

ionelmc commented 3 years ago

Ooof I almost gave up, the async apis are quite messy with lots of shortcircuits in the interpreter. I got the slots/simple implementations working in https://github.com/ionelmc/python-lazy-object-proxy/tree/async-methods - give em a try.

The cext (default one) is currently broken until I figure out a better way to implement __await__ 😕

garyd203 commented 3 years ago

Thanks @ionelmc that's really helpful of you. I unfortunately don't have time to try it out this week, but I will give it a go on my use case next week.