<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jan 19, 2012, at 4:41 PM, Greg wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Glyph wrote:<br><blockquote type="cite">[Guido] mentions the point that coroutines that can implicitly switch out from under you have the same non-deterministic property as threads: you don't know where you're going to need a lock or lock-like construct to update any variables, so you need to think about concurrency more deeply than if you could explicitly always see a 'yield'.<br></blockquote><br>I'm not convinced that being able to see 'yield's will help<br>all that much.</div></blockquote><div><br></div><div>Well, apparently we disagree, and I work on such a system all day, every day :-). &nbsp;It was nice to see that Matt Joiner also agreed for very similar reasons, and at least I know I'm not crazy.</div><br><blockquote type="cite"><div>In any system that makes substantial use of<br>generator-based coroutines, you're going to see 'yield from's<br>all over the place, from the lowest to the highest levels.<br>But that doesn't mean you need a correspondingly large<br>number of locks. You can't look at a 'yield' and conclude<br>that you need a lock there or tell what needs to be locked.<br></div></blockquote><div><br></div><div>Yes, but you <i>can</i>&nbsp;look at a 'yield' and conclude that you <i>might</i>&nbsp;need a lock, and that you have to think about it.</div><div><br></div><div>Further exploration of my own feelings on the subject grew a bit beyond a good length for a reply here, so if you're interested in my thoughts you can have a look at my blog: &lt;<a href="http://glyph.twistedmatrix.com/2012/01/concurrency-spectrum-from-callbacks-to.html">http://glyph.twistedmatrix.com/2012/01/concurrency-spectrum-from-callbacks-to.html</a>&gt;.</div><div><br></div><blockquote type="cite"><div>There's no substitute for deep thought where any kind of&nbsp;theading is involved, IMO.<br></div></blockquote></div><br><div>Sometimes there's no alternative, but wherever I can, I avoid thinking, especially hard thinking. &nbsp;This maxim has served me very well throughout my programming career ;-).</div><div><br></div><div>-glyph</div><div><br></div></body></html>