
On Wed, 25 Apr 2018 02:24:15 -0700 Nathaniel Smith njs@pobox.com wrote:
Hi all,
I just posted another essay on concurrent API design:
https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-cons...
This is the one that finally gets at the core reasons why Trio exists; I've been trying to figure out how to write it for at least a year now. I hope you like it.
My experience is indeed that something like the nursery construct would make concurrent programming much more robust in complex cases. This is a great explanation why.
API note: I would expect to be able to use it this way:
class MyEndpoint:
def __init__(self): self._nursery = open_nursery()
# Lots of behaviour methods that can put new tasks in the nursery
def close(self): self._nursery.close()
Also perhaps more finegrained shutdown routines such as:
* Nursery.join(cancel_after=None):
wait for all tasks to join, cancel the remaining ones after the given timeout
Regards
Antoine.