This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add a tutorial for AsyncIO in the documentation
Type: Stage:
Components: Documentation Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Ludovic.Gasc, asvetlov, docs@python, matrixise, terry.reedy, vstinner, yselivanov
Priority: normal Keywords:

Created on 2016-07-20 14:42 by matrixise, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (7)
msg270876 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2016-07-20 14:42
The documentation of AsyncIO is well written for a developer, but it's a reference. We have the description of all the methods, classes, etc...

But we want to learn to develop with AsyncIO, it's difficult, because there is no many examples in this reference and we have to look for some examples on Internet.

Could we add a AsyncIO tutorial|cookbook|howto ? because we have a "Logging Cookbook" but not a "AsyncIO 101".

Thank you

Stephane
msg270878 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2016-07-20 14:53
I guess someone has to step forward -- i can propose an initial patch with the tutorial.
msg271043 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-07-22 23:56
The tutorial is happening but outside Python:
https://github.com/asyncio-doc/asyncio-doc

I suggest to now close this issue.
msg271121 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-07-24 02:09
I would like the tutorial to include something like the following.

Adding Tkinter GUI to Asyncio Program
-------------------------------------

Assuming that the tkinter Tk instance is called 'root' and the asyncio loop is called 'loop', add the following callback loop.

def tk_update():
    root.update()
    loop.call_soon(tk_update)

Before each loop.run_forever() or loop.run_until_complete(...) call, add

tk_update()

Do not call root.mainloop() or root.quit().  Loop.stop() or completion of run_until_complete will stop the tk_update loop.
---

This is the result of my experiments in #27546.  One of my tests was running IDLE with an asyncio loop augmented with the above replacing root.mainloop.  I don't yet know how to work with git and github.
msg271244 - (view) Author: Ludovic Gasc (Ludovic.Gasc) * Date: 2016-07-25 09:09
Hi Terry,

>  I don't yet know how to work with git and github.

I don't yet know how to work with tkinter and TK.

I propose to combine our respective knowledge to improve the documentation together.

If you give an all in one python file example with tkinter, I'll add that in the documentation via git and Github.

Thanks for your help.

Have a nice day.
msg271245 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-07-25 09:29
"I would like the tutorial to include something like the following: Adding Tkinter GUI to Asyncio Program"

Please open an issue in the asyncio-doc project:
https://github.com/asyncio-doc/asyncio-doc

There is now a small community working on this documentation project, so I don't think that it's worth to keep this issue open.

But today, Tkinter is not really fully integrated with asyncio. So I'm not sure that it's only a matter of *documentation*, it's more a matter of code that should be written and/or completed no?

Or maybe open a thread on the new async-sig mailing list?
http://asyncio.readthedocs.io/en/latest/getting_help.html
msg271317 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-07-26 01:43
Ludovic: Thank you for the offer.  When I post a proposed text with code to #27546, I will nosy you if you have not already done so by then.

Viktor: 'full integration' by adding a tk update in the standard _run_once is not possible as tkinter is not always present.  I started #27546 by creating a custom subclass, but that requires dealing with the Selector and Proactor subclasses and default loop policy and still will not work with independent implementations.  I considered a tk-loop implementation, but speed tests do not make that very inviting. The simple code I then tried is my current best recommendation.  It will work with any asyncio compatible implementation.  Besides the test with IDLE, Guido tested it with Examples/crawl.py, and I will improve on that.
History
Date User Action Args
2022-04-11 14:58:34adminsetgithub: 71766
2016-07-26 01:43:21terry.reedysetmessages: + msg271317
2016-07-25 09:29:37vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg271245
2016-07-25 09:09:12Ludovic.Gascsetmessages: + msg271244
2016-07-24 02:09:19terry.reedysetmessages: + msg271121
2016-07-22 23:56:19vstinnersetmessages: + msg271043
2016-07-22 21:24:20terry.reedysetnosy: + terry.reedy
2016-07-20 16:32:32Ludovic.Gascsetnosy: + Ludovic.Gasc
2016-07-20 14:53:26yselivanovsetmessages: + msg270878
2016-07-20 14:42:29matrixisecreate