rheon.thread_pool_size¶
- rheon.thread_pool_size(*, threads: int | None = None) int[source]¶
The number of threads a bank given this
threadsargument runs on.Use it to see how many threads a bank will use before you build one, or what
RHEON_MAX_THREADSgives. Polars’ own threads are separate, set byPOLARS_MAX_THREADS, andpl.thread_pool_size()reports those.Parameters
threadsThe count a bank would be given, as
ModelBanktakes it.None, the default, names the process’s shared threads, which every bank given nothreadsruns on.RHEON_MAX_THREADSsets their number when they are first used (unset or0: one thread per core), and the number never changes after that. This call starts them if nothing has yet. An integernnamesnthreads, which this call checks without starting them.
Returns
int: the number of threads.Raises
TypeErrorthreadsis not an integer, a bool included.ValueErrorthreadsis below 1, or above 1024 (or the machine’s core count, where that is larger); orthreadsisNoneandRHEON_MAX_THREADSis set to anything but a whole number, or to a count past the same bound. More threads than cores run no faster, and a pool starts all of its threads at once. A bank refuses the same values: athreadswhen it is made, and a badRHEON_MAX_THREADSat its first call that runs. Both are checked before any thread starts.
Examples
print(rp.thread_pool_size(threads=2)) # 2: checked, and no thread starts
2
See also
ModelBank, whosethreadsargument this reads.