Skip to content

Commit c60ff81

Browse files
committed
uasyncio.core: Avoid wrapping coroutines to lambdas for add_reader/writer.
add_reader/writer default behavior is to schedule "callback" on I/O completion via call_soon(), there's no need to have lambda for that.
1 parent b4b19f1 commit c60ff81

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

uasyncio.core/uasyncio/core.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ def wait(self, delay):
4444
log.debug("Sleeping for: %s", delay)
4545
time.sleep(delay)
4646

47-
# Workaround bug for in uPy - default args for lambda's are not supported
48-
def lambda_helper(self, cb):
49-
def lmb(cb=cb):
50-
self.call_soon(cb)
51-
return lmb
52-
5347
def run_forever(self):
5448
while True:
5549
if self.q:
@@ -85,11 +79,11 @@ def run_forever(self):
8579
# self.add_reader(ret.obj.fileno(), lambda self, c, f: self.call_soon(c, f), self, cb, ret.obj)
8680
# self.add_reader(ret.obj.fileno(), lambda c, f: self.call_soon(c, f), cb, ret.obj)
8781
# self.add_reader(arg.fileno(), lambda cb: self.call_soon(cb), cb)
88-
self.add_reader(arg.fileno(), self.lambda_helper(cb))
82+
self.add_reader(arg.fileno(), cb)
8983
continue
9084
elif isinstance(ret, IOWrite):
9185
# self.add_writer(arg.fileno(), lambda cb: self.call_soon(cb), cb)
92-
self.add_writer(arg.fileno(), self.lambda_helper(cb))
86+
self.add_writer(arg.fileno(), cb)
9387
continue
9488
elif isinstance(ret, IOReadDone):
9589
self.remove_reader(arg.fileno())

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