Skip to content

Commit 875de44

Browse files
committed
asyncio_micro: Add support for starting a coroutine concurrently.
Just yield it as a value. Also, improve logging/error reporting.
1 parent 48671ce commit 875de44

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

asyncio_micro/asyncio_micro.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
IO_READ = 1
1111
IO_WRITE = 2
1212

13+
type_gen = type((lambda: (yield))())
1314

1415
class EventLoop:
1516

@@ -60,9 +61,9 @@ def run_forever(self):
6061
try:
6162
if args == ():
6263
args = (None,)
63-
log.debug("Gen send args: %s", args)
64+
log.debug("Gen %s send args: %s", cb, args)
6465
ret = cb.send(*args)
65-
log.debug("Gen yield result: %s", ret)
66+
log.debug("Gen %s yield result: %s", cb, ret)
6667
if isinstance(ret, SysCall):
6768
if isinstance(ret, Sleep):
6869
delay = ret.args[0]
@@ -79,6 +80,11 @@ def run_forever(self):
7980
self.remove_reader(ret.obj.fileno())
8081
elif ret.op == IO_WRITE:
8182
self.remove_writer(ret.obj.fileno())
83+
elif isinstance(ret, type_gen):
84+
self.call_soon(ret)
85+
else:
86+
print(ret, type(ret))
87+
assert False
8288
except StopIteration as e:
8389
log.debug("Gen finished: %s", cb)
8490
continue

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy