Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63406

Re: Trying to wrap my head around futures and coroutines

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; '(of': 0.07; 'nasty': 0.07; 'already.': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'blocking': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'guarded': 0.16; 'lie': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'next.': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'wrote:': 0.18; 'meant': 0.20; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; "aren't": 0.24; 'fairly': 0.24; 'cheers,': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; "i'm": 0.30; 'men': 0.31; 'front': 0.32; 'run': 0.32; 'running': 0.33; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'doubt': 0.36; 'received:com.au': 0.36; 'charset:us-ascii': 0.36; 'so,': 0.37; 'easily': 0.37; 'received:211': 0.38; 'track': 0.38; 'even': 0.60; 'above,': 0.60; 'then,': 0.60; 'course': 0.61; 'content- disposition:inline': 0.62; 'to:addr:gmail.com': 0.65; 'further,': 0.74; 'awaits': 0.84; 'but!': 0.84; 'fifty': 0.84; 'follow!': 0.84; 'fought': 0.84
Date Tue, 7 Jan 2014 13:45:21 +1100
From Cameron Simpson <cs@zip.com.au>
To Skip Montanaro <skip.montanaro@gmail.com>
Subject Re: Trying to wrap my head around futures and coroutines
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
In-Reply-To <20140107022958.GA59457@cskk.homeip.net>
User-Agent Mutt/1.5.21 (2010-09-15)
References <20140107022958.GA59457@cskk.homeip.net>
X-Optus-CM-Score 0
X-Optus-CM-Analysis v=2.1 cv=YYGEuWhf c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=LsRtkfLaIPgA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=1Lml2Qfg354A:10 a=X_-Y47qNNn8sTxwHgO0A:9 a=CjuIK1q_8ugA:10
Cc Python <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5115.1389062734.18130.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389062734 news.xs4all.nl 2959 [2001:888:2000:d::a6]:52949
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63406

Show key headers only | View raw


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@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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Trying to wrap my head around futures and coroutines Cameron Simpson <cs@zip.com.au> - 2014-01-07 13:45 +1100

csiph-web