On 8/11/2016 11:55 PM, Lawrence D’Oliveiro wrote:
On Friday, August 12, 2016 at 2:25:05 AM UTC+12, Terry Reedy wrote:
When I read something like "Python finally acquired an event loop in
3.4" I wonder where people have been. The tk event loop has been in
Python perhaps for 2 decades...
As wa
On 08/11/2016 10:47 PM, Paul Rudin wrote:
Steven D'Aprano writes:
[...]
In this case, all the work is pure computation, so I don't expect to save
any time by doing this, because the work is still all being done in the
same process/thread, not in parallel. It may even take a little bit longer,
On Saturday, August 13, 2016 at 8:26:05 PM UTC+12, Marko Rauhamaa wrote:
> ... (unless Python takes Linux's AIO API into use, which
> would be groundbreaking).
Last I looked, asynchronous I/O on Linux was still a work in progress. The
whole POSIX API has been grounded in the assumption that all
On 08/11/2016 07:14 AM, Steven D'Aprano wrote:
On Thu, 11 Aug 2016 03:06 pm, Paul Rubin wrote:
The basic characteristic of asynchronous programming is that it involves
changing all your usual blocking i/o calls to non-blocking ones, so your
program can keep running as soon as your request is st
Marko Rauhamaa writes:
> Also, one must be careful with file access, which is necessarily
> blocking on linux (unless Python takes Linux's AIO API into use, which
> would be groundbreaking).
AIO is a possibility for i/o on an already-open file and I think there
may be other ways to do it too. Bu
Paul Rubin :
> Keep in mind that the above basically takes the task off the list of
> runnables for 0.2 seconds, so it sits doing nothing and doesn't
> interfere with other tasks running. In the case where you're doing
> actual computation, you want to yield (await) much more often than 0.2
> sec,
Steven D'Aprano writes:
>> await asyncio.sleep(0.2) # pretend to do some real work
> That is *awesome*. Thank you for the example!
Keep in mind that the above basically takes the task off the list of
runnables for 0.2 seconds, so it sits doing nothing and doesn't
interfere with other tas
On Fri, 12 Aug 2016 03:47 pm, Paul Rudin wrote:
> Steven D'Aprano writes:
>
>> Thanks to everyone who has answered, I think I'm slowly starting to get
>> it now. Let's see if we can come up with a toy example that doesn't
>> involve low-level socket programming :-)
>>
>> Let me simulate a slow f
Steven D'Aprano writes:
> Thanks to everyone who has answered, I think I'm slowly starting to get it
> now. Let's see if we can come up with a toy example that doesn't involve
> low-level socket programming :-)
>
> Let me simulate a slow function call:
>
>
> import random, time
>
> def work(id):
Steven D'Aprano writes:
> How do I write work() so that it cooperatively multi-tasks with other ...
> threads? processes? what the hell do we call these things? What does this
> example become in the asynchronous world?
If it's heavily computational then you have to yield to the scheduler
frequen
On Friday, August 12, 2016 at 2:25:05 AM UTC+12, Terry Reedy wrote:
> When I read something like "Python finally acquired an event loop in
> 3.4" I wonder where people have been. The tk event loop has been in
> Python perhaps for 2 decades...
As was pointed out to me just a few days ago, that’
On Fri, Aug 12, 2016 at 10:08 AM, Steven D'Aprano
wrote:
> Let me simulate a slow function call:
>
>
> import random, time
>
> def work(id):
> print("starting with id", id)
> workload = random.randint(5, 15)
> for i in range(workload):
> time.sleep(0.2) # pretend to do some re
Thanks to everyone who has answered, I think I'm slowly starting to get it
now. Let's see if we can come up with a toy example that doesn't involve
low-level socket programming :-)
Let me simulate a slow function call:
import random, time
def work(id):
print("starting with id", id)
work
Steven D'Aprano writes:
> But what's the point in doing it asynchronously if I have to just wait for
> it to complete?
> begin downloading in an async thread
> twiddle thumbs, doing nothing
> process download
Suppose the remote server is overloaded so it sends files much slower
than your in
On Fri, Aug 12, 2016 at 12:55 AM, Steven D'Aprano
wrote:
> On Thu, 11 Aug 2016 02:41 pm, Chris Angelico wrote:
>
>> Consider these three ways of doing a database transaction:
>>
>> def synchronous(id):
>> trn = conn.begin_transaction()
>> trn.execute("select name from people where id=%d",
On Thu, 11 Aug 2016 03:34 pm, Paul Rudin wrote:
> Steven D'Aprano writes:
>
>>
>> Is there a good beginner's tutorial introducing the basics of
>> asynchronous programming? Starting with, why and where would you use it?
>
> You could do worse than watch Dave Beazley's pycon talk:
> https://www.
Steven D'Aprano writes:
>
> But what's the point in doing it asynchronously if I have to just wait for
> it to complete?
>
> begin downloading in an async thread
> twiddle thumbs, doing nothing
> process download
If you have nothing else to do, then there's no point.
But suppose you're im
Michael Selik writes:
> On Thu, Aug 11, 2016 at 11:46 AM Michael Selik
> wrote:
>
>> On Thu, Aug 11, 2016 at 11:01 AM Steven D'Aprano <
>> steve+pyt...@pearwood.info> wrote:
>>
>>> That ... looks wrong. You're taking something which looks like a procedure
>>> in the first case (trn.execute), so
On Thu, Aug 11, 2016 at 11:46 AM Michael Selik
wrote:
> On Thu, Aug 11, 2016 at 11:01 AM Steven D'Aprano <
> steve+pyt...@pearwood.info> wrote:
>
>> That ... looks wrong. You're taking something which looks like a procedure
>> in the first case (trn.execute), so it probably returns None, and yiel
On Thu, Aug 11, 2016 at 11:01 AM Steven D'Aprano
wrote:
> That ... looks wrong. You're taking something which looks like a procedure
> in the first case (trn.execute), so it probably returns None, and yielding
> over it. Even it that's not wrong, and it actually returned something which
> you ign
On Thu, 11 Aug 2016 02:41 pm, Chris Angelico wrote:
> Consider these three ways of doing a database transaction:
>
> def synchronous(id):
> trn = conn.begin_transaction()
> trn.execute("select name from people where id=%d", (id,))
> name, = trn.fetchone()
> trn.execute("update peo
Steven D'Aprano :
> Say I want to download data from a network, and it will take a long
> time. If I can do the read in parallel to something else, that makes
> sense:
>
> begin downloading in another thread/process
> make a coffee
> process download
>
> But what's the point in doing it asyn
On Thu, 11 Aug 2016 03:06 pm, Paul Rubin wrote:
> The basic characteristic of asynchronous programming is that it involves
> changing all your usual blocking i/o calls to non-blocking ones, so your
> program can keep running as soon as your request is started.
That's the bit that confuses me. I u
Steven D'Aprano :
> Instructions unclear, poked myself in the eye with a sharp stick.
I have updated my Dining Philosophers example for Python 3.5:
http://pacujo.net/~marko/philosophers.py>
It demonstrates how to get an event loop and start a number of asyncs
concurrently.
Marko
--
https:
On 8/11/2016 2:34 AM, Christian Gollwitzer wrote:
Am 11.08.16 um 06:38 schrieb Terry Reedy:
You might be able to glean something from the succession of files I
uploaded to
https://bugs.python.org/issue27546
Integrate tkinter and asyncio (and async)
I started with just mixing tk and asyncio call
On Thu, 11 Aug 2016 07:33 pm, Chris Angelico wrote:
> Yes,
> threading bugs can be harder to debug; but only when you've violated
> the other principles.
Especially the principle "Avoid threaded programming".
Some people, when faced with a problem, Now they think "I know, I'll have
use two thre
On Thu, 11 Aug 2016 03:34 pm, Paul Rudin wrote:
> Steven D'Aprano writes:
>
>>
>> Is there a good beginner's tutorial introducing the basics of
>> asynchronous programming? Starting with, why and where would you use it?
>
> You could do worse than watch Dave Beazley's pycon talk:
> https://www.
Chris Angelico :
> On Thu, Aug 11, 2016 at 5:55 PM, Marko Rauhamaa wrote:
>> My favorite asynchronous development model is the "callback hell," where
>> each cell of the state/event matrix is represented by a method (or at
>> least a switch case in C) and each state has an explicit name in the
>>
Chris Angelico writes:
> On Thu, Aug 11, 2016 at 7:45 PM, Steven D'Aprano
> wrote:
>> I don't know whether you would call that a callback. I suppose it could be,
>> in
>> the sense that you might say:
>>
>> button.set_mouseup_function(mouseUp)
>>
>> but I'm used to thinking of it as a prope
On Thu, Aug 11, 2016 at 7:45 PM, Steven D'Aprano
wrote:
> I don't know whether you would call that a callback. I suppose it could be, in
> the sense that you might say:
>
> button.set_mouseup_function(mouseUp)
>
> but I'm used to thinking of it as a property of the button.
"Callback" simply m
On Thursday 11 August 2016 16:21, Christian Gollwitzer wrote:
> In typical GUI code, there are usually not that many places qhere ou
> have sequential code. A simple exmaple might be a counter. Using asyncio
> and a properly integrated GUI toolkit, you could write it as (pseudo-code)
>
> async de
On Thu, Aug 11, 2016 at 5:55 PM, Marko Rauhamaa wrote:
> Chris Angelico :
>
>> Hmm. I'm not sure about that last bit. In order to properly support
>> asynchronous I/O and the concurrency and reentrancy that that implies,
>> you basically need all the same disciplines that you would for
>> threaded
Chris Angelico :
> Hmm. I'm not sure about that last bit. In order to properly support
> asynchronous I/O and the concurrency and reentrancy that that implies,
> you basically need all the same disciplines that you would for
> threaded programming
Correct. Python's asyncio closely mirrors threads
Christian Gollwitzer writes:
> I'm convinced that it is possible to integrate Tcl's event loop with
> asyncio's loop without regular update polling. This might require a
> patch to Tkinter at the C level. For example, an easy way is to put
> Tcl/Tk in it's own thread. ...
I did something like tha
Am 11.08.16 um 06:38 schrieb Terry Reedy:
You might be able to glean something from the succession of files I
uploaded to
https://bugs.python.org/issue27546
Integrate tkinter and asyncio (and async)
I started with just mixing tk and asyncio callbacks. After some
struggle with similar question a
Am 11.08.16 um 05:53 schrieb Steven D'Aprano:
How is this the same as, or different from, event-based programming? I'm
familiar with programming in an event-based language where the interpreter
itself provides an event loop and dispatches messages to your objects
I'll just comment on that one.
Steven D'Aprano writes:
>
> Is there a good beginner's tutorial introducing the basics of asynchronous
> programming? Starting with, why and where would you use it?
You could do worse than watch Dave Beazley's pycon talk:
https://www.youtube.com/watch?v=lYe8W04ERnY
--
https://mail.python.org/ma
On Thu, Aug 11, 2016 at 3:06 PM, Paul Rubin wrote:
> The basic reason to do it is it lets you serve a lot of concurrent i/o
> channels (network connections, say) without using threads. If you want
> to read a packet, you launch a non-blocking read that returns
> immediately, and then transfer con
Steven D'Aprano writes:
> Is there a good beginner's tutorial introducing the basics of asynchronous
> programming? Starting with, why and where would you use it?
You might look at some node.js tutorials since there are about a
gazillion of them and some of them must be good. Also twistedmatrix.
On Thu, Aug 11, 2016 at 1:53 PM, Steven D'Aprano
wrote:
> How is this the same as, or different from, event-based programming? I'm
> familiar with programming in an event-based language where the interpreter
> itself provides an event loop and dispatches messages to your objects:
>
> - I define ob
On 8/10/2016 11:53 PM, Steven D'Aprano wrote:
The latest versions of Python are introducing new keywords for
asynchronous programming, async and await. See PEP 492:
https://www.python.org/dev/peps/pep-0492/
Is there a good beginner's tutorial introducing the basics of
asynchronous programming?
41 matches
Mail list logo