Asynchronous processing is more efficient -- surely not?

2018-04-04 Thread Steven D'Aprano
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 traction in the past few years, and for good

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 c

OSError: [Errno -9981] Input overflowed

2018-04-04 Thread asphjt--- via Python-list
Here is my code: import pyaudio tim=1 chunk = 8 FORMAT = pyaudio.paInt16 CHANNELS = 1 RATE = 5 p = pyaudio.PyAudio() s = p.open(format = FORMAT,channels = CHANNELS,rate = RATE,input = True,output=True,frames_per_buffer = chunk) d=[] print((RATE // chunk

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 exper

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 efficient." > > I can agree with the first part

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 brain. > > "Asynchronous programming has

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 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 is something you'd have

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 download example. When you ar

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 every

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 library > that I use

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 down

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 i

Re: julian 0.14 library

2018-04-04 Thread Thomas Jollans
On 2018-04-04 05:44, Chris Angelico wrote: > On Wed, Apr 4, 2018 at 12:24 PM, sum abiut wrote: >> Hi, >> Has anyone try this https://pypi.python.org/pypi/julian/0.14 >> >> i got this error trying to import julian >> > import julian >> Traceback (most recent call last): >> File "", line 1, in

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. Except that I have

Re: julian 0.14 library

2018-04-04 Thread sum abiut
I got the error below, tryinig in on python 3.2. import julian Traceback (most recent call last): File "", line 1, in ImportError: No module named julian On Thu, Apr 5, 2018 at 3:21 AM, Thomas Jollans wrote: > On 2018-04-04 05:44, Chris Angelico wrote: > > On Wed, Apr 4, 2018 at 12:24 PM,

Re: julian 0.14 library

2018-04-04 Thread Dale Marvin via Python-list
>> On 2018-04-04 05:44, Chris Angelico wrote: >>> On Wed, Apr 4, 2018 at 12:24 PM, sum abiut wrote: Hi, Has anyone try this https://pypi.python.org/pypi/julian/0.14 i got this error trying to import julian >>> import julian Traceback (most recent call last): >>>

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 t

Is pdb suitable for debugging asyncio module?

2018-04-04 Thread jfong
I have a module below and run it under pdb, the result seems not easy to xplain. (Note: the sleep periods are in reverse order) --- # asyncio_as_completed.py import asyncio @asyncio.coroutine def phase(i): print('in phase {}'.format(i)) yield from asyncio.sleep(0.5 - (0.1 * i)

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

2018-04-04 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 programming has been gaining a lot of tractio