Re: Periodic execution with asyncio

2013-11-26 Thread Tobias M.
Thanks Phil, now I understand! I wasn't aware of the fact that tasks are automatically attached to the event loop when they are created via their constructor. I thought I have to pass them to a run_* method explicitly. Phil Connell schrieb: >On Sat, Nov 23, 2013 at 09:30:29PM +0100, Tobias M

Re: Periodic execution with asyncio

2013-11-25 Thread Phil Connell
On Sat, Nov 23, 2013 at 09:30:29PM +0100, Tobias M. wrote: > Now putting this into a PeriodicTask class that provides a similar interface > like our callback version, I get: > > > import asyncio > > class PeriodicTask2(object): > > def __init__(self, func, interval): > self.func =

Re: Periodic execution with asyncio

2013-11-23 Thread Tobias M.
Thanks a lot for your helpful posts, Terry! On 11/23/2013 01:00 AM, Terry Reedy wrote: * Make the task function a parameter 'func'. I actually like subclassing, but yes I know there are some downsides :) * Rename start to _set to better describe what is does and call it in the _run function

Re: Periodic execution with asyncio

2013-11-22 Thread Terry Reedy
On 11/22/2013 7:00 PM, Terry Reedy wrote: On 11/22/2013 4:30 PM, Tobias M. wrote: [snip callback versions by Tobias and me] 2. How would you implement the second approach from the PEP (using a coroutine) with the same interface as my PeriodicTask above? Theoretically, by Guido's rationale,

Re: Periodic execution with asyncio

2013-11-22 Thread Terry Reedy
On 11/22/2013 4:30 PM, Tobias M. wrote: I am using the asyncio package (Codename 'Tulip'), which will be available in Python 3.4, for the first time. Great. New stuff, both behavior and API, needs to be 'exercised', especially by non-experts in the subject. I have no experience with async s