| Store | Cart

Re: [Python-Dev] Importance of "async" keyword

From: Jim J. Jewett <jimj...@gmail.com>
Fri, 26 Jun 2015 18:51:07 -0700 (PDT)

On Fri Jun 26 16:51:13 CEST 2015, Paul Sokolovsky wrote:

> So, currently in Python you know if you do:>    socket.write(buf)> Then you know it will finish without interruptions for entire buffer.

How do you know that?

Are you assuming that socket.write is a builtin, rather than a
python method?  (Not even a python wrapper around a builtin?)

Even if that were true, it would only mean that the call itself
is processed within a single bytecode ... there is no guarantee
that the write method won't release the GIL or call back into
python (and thereby allow a thread switch) as part of its own
logic.

> And if you write:>    await socket.write(buf)> then you know there may be interruption points inside socket.write(),> in particular something else may mutate it while it's being written.

I would consider that external mutation to be bad form ... at least
as bad as violating the expectation of an atomic socket.write() up
above.

So either way, nothing bad SHOULD happen, but it might anyhow.  I'm
not seeing what the async-coloring actually bought you...

-jJ

--

If there are still threading problems with my replies, please
email me with details, so that I can try to resolve them.  -jJ
_______________________________________________
Python-Dev mailing list
Pyth...@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: https://mail.python.org/mailman/options/python-dev/python-dev-ml%40activestate.com

Recent Messages in this Thread
Jim J. Jewett Jun 27, 2015 01:51 am
Paul Sokolovsky Jun 26, 2015 02:51 pm
Chris Angelico Jun 26, 2015 03:10 pm
R. David Murray Jun 26, 2015 04:07 pm
Chris Angelico Jun 26, 2015 04:20 pm
Messages in this thread