@@ -201,20 +201,28 @@ def __init__(self, *, filepath=None, prefix=None, parent=None):
201201 self .version = self .get_version ()
202202 self .set_additional_attributes ()
203203
204- def info (self ):
205- """Return relevant info wrapped in a dict"""
204+ def info (self , extra_info : bool = False ):
205+ """Return relevant info wrapped in a dict.
206+
207+ Parameters
208+ ----------
209+ extra_info : bool
210+
211+ Include extra fields which requires more intrusive actions to
212+ obtain.
213+ """
206214 hidden_attrs = ("dynlib" , "parent" , "_symbol_prefix" , "_symbol_suffix" )
207- return {
215+ result = {
208216 "user_api" : self .user_api ,
209217 "internal_api" : self .internal_api ,
210218 "num_threads" : self .num_threads ,
211- "api_scope" : (
212- _determine_api_scope (
213- self .get_num_threads , self .set_num_threads
214- ).name .lower ()
215- ),
216219 ** {k : v for k , v in vars (self ).items () if k not in hidden_attrs },
217220 }
221+ if extra_info :
222+ result ["api_scope" ] = _determine_api_scope (
223+ self .get_num_threads , self .set_num_threads
224+ ).name .lower ()
225+ return result
218226
219227 def set_additional_attributes (self ):
220228 """Set additional attributes meant to be exposed in the info dict"""
@@ -639,7 +647,7 @@ def _realpath(filepath):
639647
640648
641649@_format_docstring (USER_APIS = list (_ALL_USER_APIS ), INTERNAL_APIS = _ALL_INTERNAL_APIS )
642- def threadpool_info ():
650+ def threadpool_info (extra_info : bool = False ):
643651 """Return the maximal number of threads for each detected library.
644652
645653 Return a list with all the supported libraries that have been found. Each
@@ -653,8 +661,18 @@ def threadpool_info():
653661 - "num_threads": the current thread limit.
654662
655663 In addition, each library may contain internal_api specific entries.
664+
665+ Parameters
666+ ----------
667+ extra_info : bool
668+
669+ Include extra fields which requires more intrusive actions to
670+ obtain.
671+
672+ - "api_scope": When setting the number of threads, what is affected.
673+ Possible values are "process", "current_thread".
656674 """
657- return ThreadpoolController ().info ()
675+ return ThreadpoolController ().info (extra_info )
658676
659677
660678class _ThreadpoolLimiter :
@@ -914,9 +932,20 @@ def _from_controllers(cls, lib_controllers):
914932 new_controller .lib_controllers = lib_controllers
915933 return new_controller
916934
917- def info (self ):
918- """Return lib_controllers info as a list of dicts"""
919- return [lib_controller .info () for lib_controller in self .lib_controllers ]
935+ def info (self , extra_info : bool = False ):
936+ """Return lib_controllers info as a list of dicts.
937+
938+ Parameters
939+ ----------
940+ extra_info : bool
941+
942+ Include extra fields which requires more intrusive actions to
943+ obtain.
944+ """
945+ return [
946+ lib_controller .info (extra_info = extra_info )
947+ for lib_controller in self .lib_controllers
948+ ]
920949
921950 def select (self , ** kwargs ):
922951 """Return a ThreadpoolController containing a subset of its current
@@ -1380,7 +1409,7 @@ def _main():
13801409 if options .command :
13811410 exec (options .command )
13821411
1383- print (json .dumps (threadpool_info (), indent = 2 ))
1412+ print (json .dumps (threadpool_info (extra_info = True ), indent = 2 ))
13841413
13851414
13861415if __name__ == "__main__" :
0 commit comments