Skip to content
Open
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
13 changes: 13 additions & 0 deletions Lib/test/libregrtest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,19 @@ def noop_search_function(name):
codecs.register(noop_search_function)
codecs.unregister(noop_search_function)

try:
_asyncio = sys.modules['_asyncio']
except KeyError:
pass
else:
_asyncio._clear_caches()

try:
asyncio_coroutines = sys.modules['asyncio.coroutines']
except KeyError:
pass
else:
asyncio_coroutines._iscoroutine_typecache.clear()

def get_build_info():
# Get most important configure and build options as a list of strings.
Expand Down
19 changes: 19 additions & 0 deletions Modules/_asynciomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4218,6 +4218,24 @@ _asyncio_future_discard_from_awaited_by_impl(PyObject *module, PyObject *fut,
Py_RETURN_NONE;
}

/*[clinic input]
_asyncio._clear_caches

Clear internal caches. Used for internal tests.
[clinic start generated code]*/

static PyObject *
_asyncio__clear_caches_impl(PyObject *module)
/*[clinic end generated code: output=9691a293f83d4303 input=6e1ae31e51dc906c]*/
{
asyncio_state *state = get_asyncio_state(module);
if (PySet_Clear(state->iscoroutine_typecache) < 0) {
return NULL;
}
Py_RETURN_NONE;
}


static int
module_traverse(PyObject *mod, visitproc visit, void *arg)
{
Expand Down Expand Up @@ -4389,6 +4407,7 @@ static PyMethodDef asyncio_methods[] = {
_ASYNCIO_ALL_TASKS_METHODDEF
_ASYNCIO_FUTURE_ADD_TO_AWAITED_BY_METHODDEF
_ASYNCIO_FUTURE_DISCARD_FROM_AWAITED_BY_METHODDEF
_ASYNCIO__CLEAR_CACHES_METHODDEF
{NULL, NULL}
};

Expand Down
20 changes: 19 additions & 1 deletion Modules/clinic/_asynciomodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading