Re: Asynchronous processing is more efficient -- surely not?

2018-04-05 Thread Paul Rudin
Steven D'Aprano writes: > So, I'm, still trying to wrap my brain around async processing, and I > started reading this tutorial: > > http://stackabuse.com/python-async-await-tutorial/ > > and the very first paragraph broke my brain. > > "Asynchronous

Re: Asynchronous processing is more efficient -- surely not?

2018-04-04 Thread Terry Reedy
On 4/4/2018 3:27 AM, Steven D'Aprano wrote: So, I'm, still trying to wrap my brain around async processing, and I started reading this tutorial: http://stackabuse.com/python-async-await-tutorial/ and the very first paragraph broke my brain. "Asynchronous programming has been gaining a lot of

Re: Asynchronous processing is more efficient -- surely not?

2018-04-04 Thread Chris Angelico
On Thu, Apr 5, 2018 at 1:48 AM, Julien Salort wrote: > Le 04/04/2018 à 14:45, Chris Angelico a écrit : >> How do you use run_in_executor to turn this asynchronous, and how >> would this compare to creating one thread for each camera? > > This is exactely like creating a thread.

Re: Asynchronous processing is more efficient -- surely not?

2018-04-04 Thread Julien Salort
Le 04/04/2018 à 14:45, Chris Angelico a écrit : Can you give an example? Let's say we have a simple blocking C function: int get_data() { sleep(2); return 42; } I am not saying that I understand 100% and that this is the best way, but it works for me: % cat get_data.c #include

Re: Asynchronous processing is more efficient -- surely not?

2018-04-04 Thread Matěj Cepl
On 2018-04-04, 07:27 GMT, Steven D'Aprano wrote: > I'm no expert, but it seems to me that this has surely got to > be crazy talk. Whatever task you're doing, processing it > asynchronously doesn't reduce the amount of work. For example, > if you want to download ten files, you still have to

Re: Asynchronous processing is more efficient -- surely not?

2018-04-04 Thread Chris Angelico
On Wed, Apr 4, 2018 at 10:16 PM, Julien Salort wrote: > In this case, the script spends most of its time waiting for a frame to be > available on the cameras, and the time interval to query the other device. > The fetching and processing of the frames take negligible time. The

Re: Asynchronous processing is more efficient -- surely not?

2018-04-04 Thread Julien Salort
Le 04/04/2018 à 09:27, Steven D'Aprano a écrit : Yes, this exactly. And if you're writing a web app, or certain kinds of desktop apps, these seems sensible. I don't want my browser to come to a complete halt just because some resource is taking a few seconds to respond. But honestly, from

Re: Asynchronous processing is more efficient -- surely not?

2018-04-04 Thread Chris Angelico
On Wed, Apr 4, 2018 at 9:02 PM, Richard Damon wrote: > Asynchronous processing will use a bit more of some processing resources > to handle the multi-processing, but it can be more efficient at fully > using many of the resources that are available. > > Take your file

Re: Asynchronous processing is more efficient -- surely not?

2018-04-04 Thread Chris Angelico
On Wed, Apr 4, 2018 at 8:42 PM, Paul Moore wrote: > IMO, > async has proved useful for handling certain types of IO bound > workloads with lower overheads[1] than traditional multi-threaded or > multi-process designs. Whether it's a good fit for any particular > application

Re: Asynchronous processing is more efficient -- surely not?

2018-04-04 Thread Richard Damon
On 4/4/18 3:27 AM, Steven D'Aprano wrote: > So, I'm, still trying to wrap my brain around async processing, and I > started reading this tutorial: > > http://stackabuse.com/python-async-await-tutorial/ > > and the very first paragraph broke my brain. > > "Asynchronous programming has been gaining

Re: Asynchronous processing is more efficient -- surely not?

2018-04-04 Thread Chris Angelico
On Wed, Apr 4, 2018 at 5:27 PM, Steven D'Aprano wrote: > So, I'm, still trying to wrap my brain around async processing, and I > started reading this tutorial: > > http://stackabuse.com/python-async-await-tutorial/ > > and the very first paragraph broke my

Re: Asynchronous processing is more efficient -- surely not?

2018-04-04 Thread Paul Moore
On 4 April 2018 at 08:27, Steven D'Aprano wrote: > "Asynchronous programming has been gaining a lot of traction in the past > few years, and for good reason. Although it can be more difficult than > the traditional linear style, it is also much more

Re: Asynchronous processing is more efficient -- surely not?

2018-04-04 Thread Jan Erik Moström
On 4 Apr 2018, at 9:27, Steven D'Aprano wrote: Its as hard to wrap your brain around as parallel processing in general, but with even worse performance than sequential processing. Am I totally wrong? I would say that it all depends on what kind of stuff you're doing. I'm no scheduling

Re: Asynchronous processing is more efficient -- surely not?

2018-04-04 Thread INADA Naoki
I agree with you. Async IO is more efficient than threading for **waiting** I/O. When there are thousands of idle connections, async I/O is best idea. On the other hand, async I/O uses more system calls for busy I/O. For example, when building chat application which handles thousands WebSocket