<div dir="ltr">I'm an author of this code but I can confirm -- usage experience is terrible.<br>Mostly because the loop don't advance virtual time only but tries to control every loop sleep. </div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jul 4, 2017 at 5:50 PM Dima Tisnek <<a href="mailto:dimaqq@gmail.com">dimaqq@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">That's good start, looks like it would satisfy asyncio-only code :)<br>
<br>
I haven't noticed that earlier.<br>
<br>
On 4 July 2017 at 16:40, Andrew Svetlov <<a href="mailto:andrew.svetlov@gmail.com" target="_blank">andrew.svetlov@gmail.com</a>> wrote:<br>
> Did you look on<br>
> <a href="https://github.com/python/cpython/blob/master/Lib/asyncio/test_utils.py#L265" rel="noreferrer" target="_blank">https://github.com/python/cpython/blob/master/Lib/asyncio/test_utils.py#L265</a><br>
> ?<br>
><br>
> On Tue, Jul 4, 2017 at 1:04 PM Dima Tisnek <<a href="mailto:dimaqq@gmail.com" target="_blank">dimaqq@gmail.com</a>> wrote:<br>
>><br>
>> Come to think of it, what sane tests need is a custom event loop or clever<br>
>> mocks around asyncio.sleep, asyncio.Condition.wait, etc. So that code under<br>
>> test never sleeps.<br>
>><br>
>> In simple cases actual delay in the event loop would raise an exception.<br>
>><br>
>> A full solution would synchronise asyncio.sleep and friends with<br>
>> time.time, time.monotonic and friends, so that a if the loop were to delay,<br>
>> it would advance global/virtual time instead. I think I saw such library for<br>
>> synchronous code, probably with limitations...<br>
>><br>
>><br>
>> In any case you should not have to add delays in your mocks or fixtures to<br>
>> hack specific order of task execution by the event loop.<br>
>><br>
>> My 2c,<br>
>> D.<br>
>><br>
>> On Jul 4, 2017 9:34 AM, "Alex Grönholm" <<a href="mailto:alex.gronholm@nextday.fi" target="_blank">alex.gronholm@nextday.fi</a>> wrote:<br>
>>><br>
>>> Yeah, but that doesn't answer my question :)<br>
>>><br>
>>><br>
>>> Chris Jerdonek kirjoitti 04.07.2017 klo 10:02:<br>
>>>><br>
>>>> On Mon, Jul 3, 2017 at 11:49 PM, Alex Grönholm<br>
>>>> <<a href="mailto:alex.gronholm@nextday.fi" target="_blank">alex.gronholm@nextday.fi</a>> wrote:<br>
>>>>><br>
>>>>> The real question is: why doesn't vanilla Sphinx have any kind of<br>
>>>>> support<br>
>>>>> for async functions which have been part of the language for quite a<br>
>>>>> while?<br>
>>>><br>
>>>> It looks like this is the issue (which Brett filed in Nov. 2015):<br>
>>>> <a href="https://github.com/sphinx-doc/sphinx/issues/2105" rel="noreferrer" target="_blank">https://github.com/sphinx-doc/sphinx/issues/2105</a><br>
>>>><br>
>>>> --Chris<br>
>>>><br>
>>>>><br>
>>>>><br>
>>>>> Nathaniel Smith kirjoitti 01.07.2017 klo 13:35:<br>
>>>>>><br>
>>>>>> If we're citing curio and sphinxcontrib-asyncio I guess I'll also<br>
>>>>>> mention sphinxcontrib-trio [1], which was inspired by both of them<br>
>>>>>> (and isn't in any way specific to trio). I don't know if the python<br>
>>>>>> docs can use third-party sphinx extensions, though, and it is a bit<br>
>>>>>> opinionated (in particular it calls async functions async functions<br>
>>>>>> instead of coroutines).<br>
>>>>>><br>
>>>>>> For the original text, I'd probably write something like::<br>
>>>>>><br>
>>>>>> You acquire a lock by calling ``await lock.acquire()``, and<br>
>>>>>> release<br>
>>>>>> it with ``lock.release()``.<br>
>>>>>><br>
>>>>>> -n<br>
>>>>>><br>
>>>>>> [1] <a href="https://sphinxcontrib-trio.readthedocs.io/en/latest/" rel="noreferrer" target="_blank">https://sphinxcontrib-trio.readthedocs.io/en/latest/</a><br>
>>>>>><br>
>>>>>> On Fri, Jun 30, 2017 at 8:31 AM, Brett Cannon <<a href="mailto:brett@python.org" target="_blank">brett@python.org</a>><br>
>>>>>> wrote:<br>
>>>>>>><br>
>>>>>>> Curio uses `.. asyncfunction:: acquire` and it renders as `await<br>
>>>>>>> acquire()`<br>
>>>>>>> at least in the function definition.<br>
>>>>>>><br>
>>>>>>> On Fri, 30 Jun 2017 at 03:36 Andrew Svetlov<br>
>>>>>>> <<a href="mailto:andrew.svetlov@gmail.com" target="_blank">andrew.svetlov@gmail.com</a>><br>
>>>>>>> wrote:<br>
>>>>>>>><br>
>>>>>>>> I like "two methods, `async acquire()` and `release()`"<br>
>>>>>>>><br>
>>>>>>>> Regarding to extra markups -- I created sphinxcontrib-asyncio [1]<br>
>>>>>>>> library<br>
>>>>>>>> for it. Hmm, README is pretty empty but we do use the library for<br>
>>>>>>>> documenting aio-libs and aiohttp [2] itself<br>
>>>>>>>><br>
>>>>>>>> We use ".. comethod:: connect(request)" for method and "cofunction"<br>
>>>>>>>> for<br>
>>>>>>>> top level functions.<br>
>>>>>>>><br>
>>>>>>>> Additional markup for methods that could be used as async context<br>
>>>>>>>> managers:<br>
>>>>>>>><br>
>>>>>>>> .. comethod:: delete(url, **kwargs)<br>
>>>>>>>> :async-with:<br>
>>>>>>>> :coroutine:<br>
>>>>>>>><br>
>>>>>>>> and `:async-for:` for async iterators.<br>
>>>>>>>><br>
>>>>>>>><br>
>>>>>>>> 1. <a href="https://github.com/aio-libs/sphinxcontrib-asyncio" rel="noreferrer" target="_blank">https://github.com/aio-libs/sphinxcontrib-asyncio</a><br>
>>>>>>>> 2. <a href="https://github.com/aio-libs/aiohttp" rel="noreferrer" target="_blank">https://github.com/aio-libs/aiohttp</a><br>
>>>>>>>><br>
>>>>>>>> On Fri, Jun 30, 2017 at 1:11 PM Dima Tisnek <<a href="mailto:dimaqq@gmail.com" target="_blank">dimaqq@gmail.com</a>><br>
>>>>>>>> wrote:<br>
>>>>>>>>><br>
>>>>>>>>> Hi all,<br>
>>>>>>>>><br>
>>>>>>>>> I'm working to improve async docs, and I wonder if/how async<br>
>>>>>>>>> methods<br>
>>>>>>>>> ought to be marked in the documentation, for example<br>
>>>>>>>>> library/async-sync.rst:<br>
>>>>>>>>><br>
>>>>>>>>> """ ... It [lock] has two basic methods, `acquire()` and<br>
>>>>>>>>> `release()`.<br>
>>>>>>>>> ...<br>
>>>>>>>>> """<br>
>>>>>>>>><br>
>>>>>>>>> In fact, these methods are not symmetric, the earlier is<br>
>>>>>>>>> asynchronous<br>
>>>>>>>>> and the latter synchronous:<br>
>>>>>>>>><br>
>>>>>>>>> Definitions are `async def acquire()` and `def release()`.<br>
>>>>>>>>> Likewise user is expected to call `await .acquire()` and<br>
>>>>>>>>> `.release()`.<br>
>>>>>>>>><br>
>>>>>>>>> This is user-facing documentation, IMO it should be clearer.<br>
>>>>>>>>> Although there are examples for this specific case, I'm concerned<br>
>>>>>>>>> with<br>
>>>>>>>>> general documentation best practice.<br>
>>>>>>>>><br>
>>>>>>>>> Should this example read, e.g.:<br>
>>>>>>>>> * two methods, `async acquire()` and `release()`<br>
>>>>>>>>> or perhaps<br>
>>>>>>>>> * two methods, used `await x.acquire()` and `x.release()`<br>
>>>>>>>>> or something else?<br>
>>>>>>>>><br>
>>>>>>>>> If there's a good example already Python docs or in some 3rd party<br>
>>>>>>>>> docs, please tell.<br>
>>>>>>>>><br>
>>>>>>>>> Likewise, should there be marks on iterators? async generators?<br>
>>>>>>>>> things<br>
>>>>>>>>> that ought to be used as context managers?<br>
>>>>>>>>><br>
>>>>>>>>> Cheers,<br>
>>>>>>>>> d.<br>
>>>>>>>>> _______________________________________________<br>
>>>>>>>>> Async-sig mailing list<br>
>>>>>>>>> <a href="mailto:Async-sig@python.org" target="_blank">Async-sig@python.org</a><br>
>>>>>>>>> <a href="https://mail.python.org/mailman/listinfo/async-sig" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/async-sig</a><br>
>>>>>>>>> Code of Conduct: <a href="https://www.python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">https://www.python.org/psf/codeofconduct/</a><br>
>>>>>>>><br>
>>>>>>>> --<br>
>>>>>>>> Thanks,<br>
>>>>>>>> Andrew Svetlov<br>
>>>>>>>> _______________________________________________<br>
>>>>>>>> Async-sig mailing list<br>
>>>>>>>> <a href="mailto:Async-sig@python.org" target="_blank">Async-sig@python.org</a><br>
>>>>>>>> <a href="https://mail.python.org/mailman/listinfo/async-sig" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/async-sig</a><br>
>>>>>>>> Code of Conduct: <a href="https://www.python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">https://www.python.org/psf/codeofconduct/</a><br>
>>>>>>><br>
>>>>>>><br>
>>>>>>> _______________________________________________<br>
>>>>>>> Async-sig mailing list<br>
>>>>>>> <a href="mailto:Async-sig@python.org" target="_blank">Async-sig@python.org</a><br>
>>>>>>> <a href="https://mail.python.org/mailman/listinfo/async-sig" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/async-sig</a><br>
>>>>>>> Code of Conduct: <a href="https://www.python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">https://www.python.org/psf/codeofconduct/</a><br>
>>>>>>><br>
>>>>>><br>
>>>>> _______________________________________________<br>
>>>>> Async-sig mailing list<br>
>>>>> <a href="mailto:Async-sig@python.org" target="_blank">Async-sig@python.org</a><br>
>>>>> <a href="https://mail.python.org/mailman/listinfo/async-sig" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/async-sig</a><br>
>>>>> Code of Conduct: <a href="https://www.python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">https://www.python.org/psf/codeofconduct/</a><br>
>>><br>
>>><br>
>>> _______________________________________________<br>
>>> Async-sig mailing list<br>
>>> <a href="mailto:Async-sig@python.org" target="_blank">Async-sig@python.org</a><br>
>>> <a href="https://mail.python.org/mailman/listinfo/async-sig" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/async-sig</a><br>
>>> Code of Conduct: <a href="https://www.python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">https://www.python.org/psf/codeofconduct/</a><br>
>><br>
>> _______________________________________________<br>
>> Async-sig mailing list<br>
>> <a href="mailto:Async-sig@python.org" target="_blank">Async-sig@python.org</a><br>
>> <a href="https://mail.python.org/mailman/listinfo/async-sig" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/async-sig</a><br>
>> Code of Conduct: <a href="https://www.python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">https://www.python.org/psf/codeofconduct/</a><br>
><br>
> --<br>
> Thanks,<br>
> Andrew Svetlov<br>
</blockquote></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr"><div>Thanks,</div>Andrew Svetlov</div></div>