Skip to content

Commit a94cdea

Browse files
committed
add get_running_loop(); remove ThreadSafeFlag
1 parent b544f2f commit a94cdea

File tree

2 files changed

+14
-29
lines changed

2 files changed

+14
-29
lines changed

Diff for: asyncio/core.py

+13
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,19 @@ def get_event_loop(runq_len=0, waitq_len=0):
446446

447447
return Loop
448448

449+
# CIRCUITPY-CHANGE: added, to match CPython
450+
def get_running_loop():
451+
"""Return the event loop used to schedule and run tasks. See `Loop`."""
452+
453+
return Loop
454+
455+
456+
def get_event_loop(runq_len=0, waitq_len=0):
457+
# CIRCUITPY-CHANGE: doc
458+
"""Return the event loop used to schedule and run tasks. See `Loop`. Deprecated and will be removed later."""
459+
460+
# CIRCUITPY-CHANGE
461+
return get_running_loop()
449462

450463
def current_task():
451464
# CIRCUITPY-CHANGE: doc

Diff for: asyncio/event.py

+1-29
Original file line numberDiff line numberDiff line change
@@ -72,32 +72,4 @@ async def wait(self):
7272
return True
7373

7474

75-
# MicroPython-extension: This can be set from outside the asyncio event loop,
76-
# such as other threads, IRQs or scheduler context. Implementation is a stream
77-
# that asyncio will poll until a flag is set.
78-
# Note: Unlike Event, this is self-clearing after a wait().
79-
try:
80-
import io
81-
82-
class ThreadSafeFlag(io.IOBase):
83-
def __init__(self):
84-
self.state = 0
85-
86-
def ioctl(self, req, flags):
87-
if req == 3: # MP_STREAM_POLL
88-
return self.state * flags
89-
return -1 # Other requests are unsupported
90-
91-
def set(self):
92-
self.state = 1
93-
94-
def clear(self):
95-
self.state = 0
96-
97-
async def wait(self):
98-
if not self.state:
99-
yield core._io_queue.queue_read(self)
100-
self.state = 0
101-
102-
except ImportError:
103-
pass
75+
# CIRCUITPY: remove ThreadSafeFlag

0 commit comments

Comments
 (0)