@@ -719,29 +719,39 @@ So does an unrecognized ID.");
719
719
720
720
721
721
static PyObject *
722
- interp_list_all (PyObject * self , PyObject * Py_UNUSED ( ignored ) )
722
+ interp_list_all (PyObject * self , PyObject * args , PyObject * kwargs )
723
723
{
724
+ static char * kwlist [] = {"require_ready" , NULL };
725
+ int reqready = 0 ;
726
+ if (!PyArg_ParseTupleAndKeywords (args , kwargs ,
727
+ "|$p:" MODULE_NAME_STR ".list_all" ,
728
+ kwlist , & reqready ))
729
+ {
730
+ return NULL ;
731
+ }
732
+
724
733
PyObject * ids = PyList_New (0 );
725
734
if (ids == NULL ) {
726
735
return NULL ;
727
736
}
728
737
729
738
PyInterpreterState * interp = PyInterpreterState_Head ();
730
739
while (interp != NULL ) {
731
- PyObject * item = get_summary (interp );
732
- if (item == NULL ) {
733
- Py_DECREF (ids );
734
- return NULL ;
735
- }
740
+ if (!reqready || _PyInterpreterState_IsReady (interp )) {
741
+ PyObject * item = get_summary (interp );
742
+ if (item == NULL ) {
743
+ Py_DECREF (ids );
744
+ return NULL ;
745
+ }
736
746
737
- // insert at front of list
738
- int res = PyList_Insert (ids , 0 , item );
739
- Py_DECREF (item );
740
- if (res < 0 ) {
741
- Py_DECREF (ids );
742
- return NULL ;
747
+ // insert at front of list
748
+ int res = PyList_Insert (ids , 0 , item );
749
+ Py_DECREF (item );
750
+ if (res < 0 ) {
751
+ Py_DECREF (ids );
752
+ return NULL ;
753
+ }
743
754
}
744
-
745
755
interp = PyInterpreterState_Next (interp );
746
756
}
747
757
@@ -1417,8 +1427,8 @@ static PyMethodDef module_functions[] = {
1417
1427
METH_VARARGS | METH_KEYWORDS , create_doc },
1418
1428
{"destroy" , _PyCFunction_CAST (interp_destroy ),
1419
1429
METH_VARARGS | METH_KEYWORDS , destroy_doc },
1420
- {"list_all" , interp_list_all ,
1421
- METH_NOARGS , list_all_doc },
1430
+ {"list_all" , _PyCFunction_CAST ( interp_list_all ) ,
1431
+ METH_VARARGS | METH_KEYWORDS , list_all_doc },
1422
1432
{"get_current" , interp_get_current ,
1423
1433
METH_NOARGS , get_current_doc },
1424
1434
{"get_main" , interp_get_main ,
0 commit comments