Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75126
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Question about asyncio doc example |
| Date | 2014-07-24 08:54 +0300 |
| Organization | A noiseless patient Spider |
| Message-ID | <87d2cvti80.fsf@elektro.pacujo.net> (permalink) |
| References | <CAO3PiBgEsjvWMMqZkkOUoHmyDQr4=BtprspHj1kw7itOMiZDpw@mail.gmail.com> <lqpjnu$dun$1@ger.gmane.org> <mailman.12265.1406179417.18130.python-list@python.org> |
Saimadhav Heblikar <saimadhavheblikar@gmail.com>: > For situations where I dont really know how long a function is going > to take(say waiting for user input or a network operation), I am > better off using callbacks than "yield from asyncio.sleep()". Is my > understanding correct? If you choose the coroutine style of programming, you wouldn't normally use callbacks. Instead, you would "yield from" any blocking event. There are coroutine equivalents for locking, network I/O, multiplexing etc. The callback style encodes the state in a variable. The coroutine style (which closely resembles multithreading), encodes the state in the code itself. Both styles can easily become really messy (because reality is surprisingly messy). Marko
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: Question about asyncio doc example Saimadhav Heblikar <saimadhavheblikar@gmail.com> - 2014-07-24 10:45 +0530 Re: Question about asyncio doc example Marko Rauhamaa <marko@pacujo.net> - 2014-07-24 08:54 +0300
csiph-web