diff --git a/winloop/_noop.py b/winloop/_noop.py deleted file mode 100644 index bfc14dc..0000000 --- a/winloop/_noop.py +++ /dev/null @@ -1,3 +0,0 @@ -def noop() -> None: - """Empty function to invoke CPython ceval loop.""" - return diff --git a/winloop/includes/compat.h b/winloop/includes/compat.h index 8705e60..d316bc4 100644 --- a/winloop/includes/compat.h +++ b/winloop/includes/compat.h @@ -183,5 +183,9 @@ void PyOS_AfterFork_Child() { // TODO: all versions of _PyEval_EvalFrameDefault so we can get rid of _noop.noop // which would be a massive performance enhancement and allow pyinstaller to compile 3.9 -> 3.14 +// PyObject* PerfomNoop(){ +// PyEval_EvalCode() +// } + #endif // __WINLOOP_COMPAT_H__ \ No newline at end of file diff --git a/winloop/loop.pxd b/winloop/loop.pxd index 131a3de..806b34d 100644 --- a/winloop/loop.pxd +++ b/winloop/loop.pxd @@ -200,7 +200,9 @@ cdef class Loop: cdef _handle_signal(self, sig) cdef _read_from_self(self) - cdef inline int _ceval_process_signals(self) except -1 + # We label _ceval_process_signals as noexcept since we want to try + # and handle exceptions after all signals have been invoked. + cdef inline _ceval_process_signals(self) cdef _invoke_signals(self, bytes data) cdef _set_coroutine_debug(self, bint enabled) diff --git a/winloop/loop.pyx b/winloop/loop.pyx index 0e6d9cf..1f41d11 100644 --- a/winloop/loop.pyx +++ b/winloop/loop.pyx @@ -35,21 +35,7 @@ from .includes.python cimport (PY_VERSION_HEX, Context_CopyCurrent, PyOS_BeforeFork, PyUnicode_EncodeFSDefault, PyUnicode_FromString, _Py_RestoreSignals) -# NOTE: Keep if we need to revert at any point in time... -from ._noop import noop - -# NOTE: This has a theoretical chance of hepling to safely bypass the required _noop module... -# The only thing that will need simulations is hitting Ctrl+C on a keyboard which is not easy -# to simulate. For now I'll comment this out we can go back to it in a later winloop 0.2.XX version -# __noop_locals = {} -# exec("def noop(): return", {}, __noop_locals) -# cdef object noop = __noop_locals['noop'] -# # never need __noop_locals again... -# del __noop_locals - - include "includes/stdlib.pxi" - include "errors.pyx" cdef: @@ -456,20 +442,24 @@ cdef class Loop: def __sighandler(self, signum, frame): self._signals.add(signum) - cdef inline int _ceval_process_signals(self) except -1: + cdef inline _ceval_process_signals(self): # Invoke CPython eval loop to let process signals. - if PyErr_CheckSignals() < 0: - return -1 + # Reason for getting rid of noop has more to do with + # pyinstaller and making executable files with winloop + + # All in all a smarter approch was wanted due to pyinstaller but also + # due to needing some more juicy speedups - # Might be gotten rid of soon, since we want to improve evaluation: # SEE: https://github.com/Vizonex/Winloop/issues/58 - # Calling a pure-Python function will invoke - # _PyEval_EvalFrameDefault which will process - # pending signal callbacks. - if PyObject_CallNoArgs(noop) == NULL: # Might raise ^C - return -1 - return 0 + PyErr_CheckSignals() + + # Calling a pure-Python function (this can also be literally any from) + # will invoke _PyEval_EvalFrameDefault which will process + # pending signal callbacks this attempts to get rid of needing another external module + eval("None") + + cdef _read_from_self(self): cdef bytes sigdata @@ -489,7 +479,6 @@ cdef class Loop: cdef _invoke_signals(self, bytes data): cdef set sigs - self._ceval_process_signals() sigs = self._signals.copy()