Trying to wrap my head around futures and coroutines

Cameron Simpson cs at zip.com.au
Mon Jan 6 21:45:21 EST 2014


On 07Jan2014 13:29, I wrote:
>   def do_A():
>     with lock_B():
>       with lock_A():
>         _do_A()

Um, of course there would be a cancel_B() up front above, like this:

  def do_A():
    cancel_B()
    with lock_B():
      with lock_A():
        _do_A()

I'm with MRAB: you don't really need futures unless you looking to
move to a multithreaded appraoch and aren't multithreaded already.
Even then, you don't need futures, just track running threads and
what's meant to run next.

You can do all your blocking with Locks fairly easily unless there
are complexities not yet revealed. (Of course, this is a truism,
but I mean "conveniently".)

Cheers,
-- 
Cameron Simpson <cs at zip.com.au>

Follow! But! Follow only if ye be men of valor, for the entrance to this cave
is guarded by a creature so foul, so cruel that no man yet has fought with it
and lived! Bones of four fifty men lie strewn about its lair.  So,
brave knights, if you do doubt your courage or your strength, come no
further, for death awaits you all with nasty big pointy teeth.
- Tim The Enchanter



More information about the Python-list mailing list