1
1
#include "Python.h"
2
2
#include "pycore_call.h" // _PyObject_CallNoArgs()
3
+ #include "pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION
3
4
#include "pycore_dict.h" // _PyDict_Pop_KnownHash()
4
5
#include "pycore_long.h" // _PyLong_GetZero()
5
6
#include "pycore_moduleobject.h" // _PyModule_GetState()
@@ -1274,7 +1275,11 @@ lru_cache_dealloc(lru_cache_object *obj)
1274
1275
static PyObject *
1275
1276
lru_cache_call (lru_cache_object * self , PyObject * args , PyObject * kwds )
1276
1277
{
1277
- return self -> wrapper (self , args , kwds );
1278
+ PyObject * result ;
1279
+ Py_BEGIN_CRITICAL_SECTION (self );
1280
+ result = self -> wrapper (self , args , kwds );
1281
+ Py_END_CRITICAL_SECTION ();
1282
+ return result ;
1278
1283
}
1279
1284
1280
1285
static PyObject *
@@ -1287,14 +1292,15 @@ lru_cache_descr_get(PyObject *self, PyObject *obj, PyObject *type)
1287
1292
}
1288
1293
1289
1294
/*[clinic input]
1295
+ @critical_section
1290
1296
_functools._lru_cache_wrapper.cache_info
1291
1297
1292
1298
Report cache statistics
1293
1299
[clinic start generated code]*/
1294
1300
1295
1301
static PyObject *
1296
1302
_functools__lru_cache_wrapper_cache_info_impl (PyObject * self )
1297
- /*[clinic end generated code: output=cc796a0b06dbd717 input=f05e5b6ebfe38645 ]*/
1303
+ /*[clinic end generated code: output=cc796a0b06dbd717 input=00e1acb31aa21ecc ]*/
1298
1304
{
1299
1305
lru_cache_object * _self = (lru_cache_object * ) self ;
1300
1306
if (_self -> maxsize == -1 ) {
@@ -1308,14 +1314,15 @@ _functools__lru_cache_wrapper_cache_info_impl(PyObject *self)
1308
1314
}
1309
1315
1310
1316
/*[clinic input]
1317
+ @critical_section
1311
1318
_functools._lru_cache_wrapper.cache_clear
1312
1319
1313
1320
Clear the cache and cache statistics
1314
1321
[clinic start generated code]*/
1315
1322
1316
1323
static PyObject *
1317
1324
_functools__lru_cache_wrapper_cache_clear_impl (PyObject * self )
1318
- /*[clinic end generated code: output=58423b35efc3e381 input=6ca59dba09b12584 ]*/
1325
+ /*[clinic end generated code: output=58423b35efc3e381 input=dfa33acbecf8b4b2 ]*/
1319
1326
{
1320
1327
lru_cache_object * _self = (lru_cache_object * ) self ;
1321
1328
lru_list_elem * list = lru_cache_unlink_list (_self );
0 commit comments