Re: [Async-sig] Optional async method and best practices

2017-07-12 Thread Nathaniel Smith
On Tue, Jul 11, 2017 at 3:26 PM, Laurent Mazuel via Async-sig wrote: > Hello, > > I’m working currently with Brett Cannon to bring asyncio support to our SDK. > We wanted to check with you one of the scenario, since we got a lng > discussion on it together 😊. And we want to do it using the b

Re: [Async-sig] Optional async method and best practices

2017-07-12 Thread Laurent Mazuel via Async-sig
Good point! I didn't see it. It will definitely happen. So I won't do that 😊 So, my best candidate right now is the "get_resource(nowait)" two methods approach. Thank you! Laurent -Original Message- From: Chris Jerdonek [mailto:chris.jerdo...@gmail.com] Sent: Wednesday, July 12, 2017 1

Re: [Async-sig] Optional async method and best practices

2017-07-12 Thread Chris Jerdonek
On Wed, Jul 12, 2017 at 9:44 AM, Laurent Mazuel via Async-sig wrote: > @property > def future(self): > if self._future is None: > self._future = asyncio.Future() > asyncio.ensure_future(self._poll()) > return self._future > > result = await poller.fu

Re: [Async-sig] Optional async method and best practices

2017-07-12 Thread Laurent Mazuel via Async-sig
Thanks Dima, Chris and Cory! This helps me a lot 😊 I like the "future" approach, I think this is exactly what I need, more than a coroutine method "result()/ready()" on my object. With a coroutine method, each time you call it you get a new coroutine, but it will poll the same set of values and

Re: [Async-sig] Optional async method and best practices

2017-07-12 Thread Dima Tisnek
Hi Laurent, I'm still a dilettante, so take my comments with a grain of salt: 1. Target Python 3.6 only. (i.e. drop 3.5; look at 3.7 obv, but you want users now) (i.e. forget `yield from`, none will remember/get it next year) (if 2.7 or 3.3 must be supported, provide synch package) 2.

Re: [Async-sig] Optional async method and best practices

2017-07-12 Thread Cory Benfield
> On 11 Jul 2017, at 23:26, Laurent Mazuel via Async-sig > wrote: > > Hello, Hi Laurent! A future note: your message got stuck in moderation because you aren’t subscribed to the mailing list. You may find it helpful to subscribe, as your future messages will also get stuck unless you do! >

Re: [Async-sig] Optional async method and best practices

2017-07-12 Thread Chris Jerdonek
On Tue, Jul 11, 2017 at 3:26 PM, Laurent Mazuel via Async-sig wrote: > But I got a warning if I decide to do not use this poller, RuntimeWarning: > coroutine 'foo' was never awaited > ... > I found 2 solutions to avoid the warning, and I currently prefer solution 2: > 1- Return a function to call

[Async-sig] Optional async method and best practices

2017-07-12 Thread Laurent Mazuel via Async-sig
Hello, I’m working currently with Brett Cannon to bring asyncio support to our SDK. We wanted to check with you one of the scenario, since we got a lng discussion on it together 😊. And we want to do it using the best reasonable practice with your opinion. We have an api that is clearly asy