| 1 | from pypy.module.cpyext.pyobject import PyObject |
| 2 | from pypy.module.cpyext.api import cpython_api, Py_ssize_t, CANNOT_FAIL, CConfig |
| 3 | from pypy.module.cpyext.object import FILEP |
| 4 | from rpython.rtyper.lltypesystem import rffi, lltype |
| 5 | from pypy.module.cpyext.pystate import PyThreadState, PyInterpreterState |
| 6 | |
| 7 | @cpython_api([], rffi.INT_real, error=CANNOT_FAIL) |
| 8 | def Py_MakePendingCalls(space): |
| 9 | return 0 |
| 10 | |
| 11 | pending_call = lltype.Ptr(lltype.FuncType([rffi.VOIDP], rffi.INT_real)) |
| 12 | @cpython_api([pending_call, rffi.VOIDP], rffi.INT_real, error=-1) |
| 13 | def Py_AddPendingCall(space, func, arg): |
| 14 | """Post a notification to the Python main thread. If successful, |
| 15 | func will be called with the argument arg at the earliest |
| 16 | convenience. func will be called having the global interpreter |
| 17 | lock held and can thus use the full Python API and can take any |
| 18 | action such as setting object attributes to signal IO completion. |
| 19 | It must return 0 on success, or -1 signalling an exception. The |
| 20 | notification function won't be interrupted to perform another |
| 21 | asynchronous notification recursively, but it can still be |
| 22 | interrupted to switch threads if the global interpreter lock is |
| 23 | released, for example, if it calls back into Python code. |
| 24 | |
| 25 | This function returns 0 on success in which case the notification |
| 26 | has been scheduled. Otherwise, for example if the notification |
| 27 | buffer is full, it returns -1 without setting any exception. |
| 28 | |
| 29 | This function can be called on any thread, be it a Python thread |
| 30 | or some other system thread. If it is a Python thread, it doesn't |
| 31 | matter if it holds the global interpreter lock or not. |
| 32 | """ |
| 33 | return -1 |
| 34 |