Skip to content

Commit 3e75c9a

Browse files
authored
Merge pull request #7138 from jepler/fix-asyncio-on-hw
Revert definition of _asyncio 'ticks()' to 8.0.0-beta2
2 parents baa44a2 + 8a2e9de commit 3e75c9a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

extmod/moduasyncio.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,18 @@ STATIC mp_obj_t task_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf);
7373
#define _TICKS_PERIOD (1lu << 29)
7474
#define _TICKS_MAX (_TICKS_PERIOD - 1)
7575
#define _TICKS_HALFPERIOD (_TICKS_PERIOD >> 1)
76-
76+
#if !CIRCUITPY || (defined(__unix__) || defined(__APPLE__))
7777
STATIC mp_obj_t ticks(void) {
7878
return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms() & _TICKS_MAX);
7979
}
80+
#else
81+
// We don't share the implementation above because our supervisor_ticks_ms
82+
// starts the epoch about 65 seconds before the first overflow (see
83+
// shared-bindings/supervisor/__init__.c). We assume/require that
84+
// supervisor.ticks_ms is picked as the ticks implementation under
85+
// CircuitPython for the Python-coded bits of asyncio.
86+
#define ticks() MP_OBJ_NEW_SMALL_INT(supervisor_ticks_ms())
87+
#endif
8088

8189
STATIC mp_int_t ticks_diff(mp_obj_t t1_in, mp_obj_t t0_in) {
8290
mp_uint_t t0 = MP_OBJ_SMALL_INT_VALUE(t0_in);

0 commit comments

Comments
 (0)