Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #111776 > unrolled thread
| Started by | "Marco S." <mail.python.org@marco.sulla.e4ward.com> |
|---|---|
| First post | 2016-07-23 02:27 +0200 |
| Last post | 2016-07-23 02:27 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
How asyncio works? and event loop vs exceptions "Marco S." <mail.python.org@marco.sulla.e4ward.com> - 2016-07-23 02:27 +0200
| From | "Marco S." <mail.python.org@marco.sulla.e4ward.com> |
|---|---|
| Date | 2016-07-23 02:27 +0200 |
| Subject | How asyncio works? and event loop vs exceptions |
| Message-ID | <mailman.68.1469234320.22221.python-list@python.org> |
I'm developing a web app based on aiohttp, and I find the event loop concept very interesting. I never programmed with it before, but I know that node.js and GUIs are based on it. What I can't understand is how asyncio make it possible to run multiple tasks concurrently, since it's single threaded (if you don't use loop.run_in_executor()). I just tried to imagine that it should act as a cpu scheduler. Is this true? If so, how and when asyncio decide to switch to another task? Furthermore I have a question about exceptions in asyncio. If I understand well how it works, tasks exceptions can be caught only if you wait for task completion, with yield from, await or loop.run_until_complete(future). But in this case the coroutine blocks the execution of the program until it returns. On the contrary you can execute the coroutine inside an asyncio task and it will be non-blocking, but in this case exceptions can't be caught in a try statement. Is this correct? If so, asyncio programming style can't be a little divergent from what was the philosophy of Python until now?
Back to top | Article view | comp.lang.python
csiph-web