Skip to content

Commit

Permalink
protect against multiprocessing use on windows because of fork issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Cleveland committed Jan 23, 2024
1 parent b61fe67 commit cb553d1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions opppy/dump_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@
import sys
import pickle
import math
import platform
from multiprocessing import Process, Manager, cpu_count

from opppy.progress import progress

USE_THREADS = os.getenv("OPPPY_USE_THREADS", 'True').lower() in ('true', '1', 't')
NTHREADS = int(os.getenv("OPPPY_N_THREADS", str(min(cpu_count(),4))))
# Protect against multiprocessing fork issue on Windows
if "windows" in platform.system().lower():
print("WARNING: DISABLING OPPPY MULTIPROCESSING THREADING ON WINDOWS SYSTEMS")
USE_THREADS = False
NTHREADS = 1

def point_value_1d(data, x_key, value_key, x_value, method='nearest'):
'''
Expand Down
6 changes: 6 additions & 0 deletions opppy/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io
import os
import math
import platform
import numpy as np
from multiprocessing import Process, Manager, cpu_count

Expand All @@ -36,6 +37,11 @@

USE_THREADS = os.getenv("OPPPY_USE_THREADS", 'True').lower() in ('true', '1', 't')
NTHREADS = int(os.getenv("OPPPY_N_THREADS", str(min(cpu_count(),4))))
# Protect against multiprocessing fork issue on Windows
if "windows" in platform.system().lower():
print("WARNING: DISABLING OPPPY MULTIPROCESSING THREADING ON WINDOWS SYSTEMS")
USE_THREADS = False
NTHREADS = 1

def append_cycle_data(cycle_data, data, sort_key_string):
'''
Expand Down
6 changes: 6 additions & 0 deletions opppy/tally.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io
import os
import math
import platform
import numpy as np
from multiprocessing import Process, Manager, cpu_count

Expand All @@ -36,6 +37,11 @@

USE_THREADS = os.getenv("OPPPY_USE_THREADS", 'True').lower() in ('true', '1', 't')
NTHREADS = int(os.getenv("OPPPY_N_THREADS", str(min(cpu_count(),4))))
# Protect against multiprocessing fork issue on Windows
if "windows" in platform.system().lower():
print("WARNING: DISABLING OPPPY MULTIPROCESSING THREADING ON WINDOWS SYSTEMS")
USE_THREADS = False
NTHREADS = 1

def append_tally_data(cycle_data, data, sort_key_string):
'''
Expand Down

0 comments on commit cb553d1

Please sign in to comment.