Skip to content

Commit

Permalink
Fix running on systems without sched_setaffinity
Browse files Browse the repository at this point in the history
  • Loading branch information
HippocampusGirl committed Apr 11, 2024
1 parent d37733c commit 1d404ee
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/gwas/src/gwas/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,26 +97,32 @@ def underscore(x: str) -> str:
return re.sub(r"([a-z\d])([A-Z])", r"\1_\2", x).lower()


def get_initargs() -> tuple[set[int], Queue[LogRecord] | None, int | str]:
def get_initargs() -> tuple[set[int] | None, Queue[LogRecord] | None, int | str]:
from .log import logging_thread

logging_queue: Queue[LogRecord] | None = None
if logging_thread is not None:
logging_queue = logging_thread.logging_queue

sched_affinity: set[int] | None = None
if hasattr(os, "sched_getaffinity"):
sched_affinity = os.sched_getaffinity(0)

return (
os.sched_getaffinity(0),
sched_affinity,
logging_queue,
logger.getEffectiveLevel(),
)


def initializer(
sched_affinity: set[int],
sched_affinity: set[int] | None,
logging_queue: Queue[LogRecord] | None,
log_level: int | str,
) -> None:
os.sched_setaffinity(0, sched_affinity)
if sched_affinity is not None:
if hasattr(os, "sched_setaffinity"):
os.sched_setaffinity(0, sched_affinity)

if logging_queue is not None:
worker_configurer(logging_queue, log_level)
Expand Down

0 comments on commit 1d404ee

Please sign in to comment.