-
-
Notifications
You must be signed in to change notification settings - Fork 371
Description
In this recent forum post, @math2001 was wondering how to implement something like trio.move_on_after, so they looked at the source... and saw a reference to _core.current_time(), which made them think that it was using spooky private APIs: https://trio.discourse.group/t/how-to-access-the-current-run-s-clock/163
Of course, that's not the goal. Nothing in the trio._core.* API is actually private – it all gets re-exported from trio.*, trio.hazmat.*, or trio.testing.*, and the whole point of having a _core API layer is to make sure that it is possible to implement your own versions of things like move_on_after. But there's no way @math2001 could have known that when they dug into the code :-). And if move_on_after had used trio.current_time() instead of _core.current_time(), then the confusion could have been avoided.
So probably we should do a pass through the files in trio/*.py, and replace references to _core.* with trio.* or trio.hazmat.* as appropriate. There might be some places where this is difficult or annoying (e.g. when implementing trio itself you can't necessarily replace from ._core import <names> with from trio import <names>, because of circular import issues), but for files like trio/_timeouts.py this would be easy to do.
Marking "good first issue" because it's pretty straightforward. For example, in trio/_timeouts.py, it'd be a matter of:
- Replacing
from . import _corewithimport trio - Replacing references to
_core.current_time→trio.current_time,_core.CancelScope→trio.CancelScope
There are a bunch of files to look through, but for a first issue it'd be fine to just pick one to start with.