[Python-ideas] Async API: some code to review

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Oct 30 06:36:10 CET 2012


Yury Selivanov wrote:
> It would be even better if we can return
> a tiny wrapper, that lets you to simply write 'doit.run().with_timeout(2.1)', 
> instead of:
> 
>     task = scheduling.Task(doit(), timeout=2.1)
>     task.start()
>     scheduling.run()

I would prefer spelling this something like

    scheduling.spawn(doit(), timeout=2.1)

A newly spawned task should be scheduled automatically; if
you're not ready for it to run yet, then don't spawn it
until you are.

Also, it should almost *never* be necessary to call
scheduling.run(). That should happen only in a very few
places, mostly buried deep inside the scheduling/event
loop system.

-- 
Greg



More information about the Python-ideas mailing list