On Sat, 9 Jun 2018 at 14:31, Michel Desmoulin <desmoulinmic...@gmail.com> wrote:
> > > Le 09/06/2018 à 12:33, Andrew Svetlov a écrit : > > If we consistently apply the idea of hook for internal python structure > > modification too many things should be changed. Import > > machinery, tracemalloc, profilers/tracers, name it. > > If your code (I still don't see the real-life example) wants to check a > > policy change -- just do it. > > > > # on initialization > > policy = asyncio.get_event_loop_policy() > > > > # somewhere in code > > if policy is not asyncio.get_event_loop_policy(): > > raise RuntimeError("Policy was changed") > > You need to repeat this check everywhere because nothing guaranty a code > hasn't change it after the check. > > While a call back allow you to catch it every time. > > You can set either raise, warn, monkey patch, disable features, etc. > IMHO, it is not any framework's job to check for this. It is a programmer error. You don't need to babysit programmers so much. Not if the cost is adding new APIs. I agree with Andrew, if we open this precedent, next thing we know, Python has to provide callbacks for any internal state changes. Why not callbacks for when modules are imported? Etc. etc. It leads to API noise. Doesn't seem to be justified in this case, since I would guess almost all applications only change event loop policy once, during startup, and never again. -- Gustavo J. A. M. Carneiro Gambit Research "The universe is always one step beyond logic." -- Frank Herbert
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/