Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions winloop/_noop.py

This file was deleted.

4 changes: 4 additions & 0 deletions winloop/includes/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__
4 changes: 3 additions & 1 deletion winloop/loop.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
39 changes: 14 additions & 25 deletions winloop/loop.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -489,7 +479,6 @@ cdef class Loop:

cdef _invoke_signals(self, bytes data):
cdef set sigs

self._ceval_process_signals()

sigs = self._signals.copy()
Expand Down
Loading