Returns the number of processors on this machine.
()
| 47 | |
| 48 | |
| 49 | def cpu_count() -> int: |
| 50 | """Returns the number of processors on this machine.""" |
| 51 | if multiprocessing is None: |
| 52 | return 1 |
| 53 | try: |
| 54 | return multiprocessing.cpu_count() |
| 55 | except NotImplementedError: |
| 56 | pass |
| 57 | try: |
| 58 | return os.sysconf("SC_NPROCESSORS_CONF") # type: ignore |
| 59 | except (AttributeError, ValueError): |
| 60 | pass |
| 61 | gen_log.error("Could not detect number of processors; assuming 1") |
| 62 | return 1 |
| 63 | |
| 64 | |
| 65 | def _reseed_random() -> None: |
no outgoing calls
no test coverage detected