[issue37088] Add a way to schedule a function to be called from the main thread

Eric Snow report at bugs.python.org
Wed May 29 16:32:13 EDT 2019


Eric Snow <ericsnowcurrently at gmail.com> added the comment:

Note that I'm working on making pending calls per-interpreter (see issue #33608 and https://github.com/python/cpython/pull/12360 (since reverted)).

As to exposing Py_AddPendingCall() as sys.addpendingcall, that might be opening a can of worms.  Injecting code into the eval loop at some arbitrary ("soon") future time requires care and the code isn't well exercised historically (much like subinterpreters).  By making it easier to use the pending calls API (e.g. from Python code) we may be introducing an attractive nuisance.  It also adds burden on other Python implementations.

My point is, let's think this through before adding sys.addpendingcall(). :)  Is there another way this could be done that doesn't open a can of worms?

Also, at the very least it should probably be a "private" function (i.e sys._addpendingcall).

----------
nosy: +eric.snow

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37088>
_______________________________________


More information about the Python-bugs-list mailing list