@@ -46,8 +46,13 @@ class EventLoopGroup(NativeResource):
4646 need to do async work will ask the EventLoopGroup for an event-loop to use.
4747
4848 Args:
49- num_threads (int): Number of event-loops to create.
50- Pass 0 to create one for each processor on the machine.
49+ num_threads (Optional[int]): Maximum number of event-loops to create.
50+ If unspecified, one is created for each processor on the machine.
51+
52+ cpu_group (Optional[int]): Optional processor group to which all
53+ threads will be pinned. Useful for systems with non-uniform
54+ memory access (NUMA) nodes. If specified, the number of threads
55+ will be capped at the number of processors in the group.
5156
5257 Attributes:
5358 shutdown_event (threading.Event): Signals when EventLoopGroup's threads
@@ -57,16 +62,26 @@ class EventLoopGroup(NativeResource):
5762
5863 __slots__ = ('shutdown_event' )
5964
60- def __init__ (self , num_threads = 0 ):
65+ def __init__ (self , num_threads = None , cpu_group = None ):
6166 super ().__init__ ()
6267
68+ if num_threads is None :
69+ # C uses 0 to indicate defaults
70+ num_threads = 0
71+
72+ if cpu_group is None :
73+ is_pinned = False
74+ cpu_group = 0
75+ else :
76+ is_pinned = True
77+
6378 shutdown_event = threading .Event ()
6479
6580 def on_shutdown ():
6681 shutdown_event .set ()
6782
6883 self .shutdown_event = shutdown_event
69- self ._binding = _awscrt .event_loop_group_new (num_threads , on_shutdown )
84+ self ._binding = _awscrt .event_loop_group_new (num_threads , is_pinned , cpu_group , on_shutdown )
7085
7186
7287class HostResolverBase (NativeResource ):
0 commit comments