Alright, so my suspicions are verified. Thanks!
--
,,,^..^,,,

On Fri, May 8, 2015 at 3:54 AM, Guido van Rossum <[email protected]> wrote:
> On Thu, May 7, 2015 at 5:13 PM, Alexander Shorin <[email protected]> wrote:
>>
>> Assume I want to make a delayed call:
>>
>>     handler = loop.call_later(delay, callback)
>>
>> How can I check if callback was called for _now_?
>
>
> You can't.
>
>>
>> Handler seems only provides a way to cancel a call, not to check it
>> status: is called, failed with exception etc.
>
>
> Correct.
>
>>
>> If the callback failed, how can I get an exception of it?
>
>
> It will be logged, but you can't catch and examine it.
>
>>
>> loop.set_exception_handler seems is designed to catch everything, but I
>> need to catch exact that callback failure.
>
>
> Correct, that's not meant for this use case.
>
>>
>> Bonus: what's the best way to delay call (delay yield from) coroutines? I
>> guess is something like that:
>>
>>     @asyncio.coroutine
>>     def yield_later(delay, coro):
>>         yield from asyncio.sleep(delay)
>>         yield from coro
>>
>>     asyncio.async(yield_later(delay, mycoro(foo, bar=baz)))
>>
>> but just want to make sure.
>
>
> But what are you doing with the return from the async() call?
>
>>
>> For now, the only solution I see is about wrap callback with additional
>> functions in order to catch and process raised exceptions, set an Event in
>> order to notify callee about callback call and so on, but doing all this I
>> have a strange feel that I miss something oblivious. So do I?
>
>
> That's indeed how you do this.
>
> Remark: you are mixing questions about callbacks and coroutines. Maybe you
> are not entirely sure about the difference between the two? They are meant
> to be used at quite different levels (in fact, coroutines make progress
> mostly when the event loop calls some callback that causes a Task or Future
> to become done).
>
> --
> --Guido van Rossum (python.org/~guido)

Reply via email to