Skip to content

Commit

Permalink
switch to multiprocess when not running on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathew Cleveland committed Jan 24, 2024
1 parent 325a0ec commit de5c777
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
12 changes: 6 additions & 6 deletions opppy/dump_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@
import pickle
import math
import platform
from multiprocessing import Process, Manager, cpu_count
import pickle
if "linux" in platform.system().lower():
from multiprocessing import Process, Manager, cpu_count
else:
# Protect against multiprocessing fork issue on Windows and Mac
from multiprocess 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 and Mac
if "linux" not in platform.system().lower():
print("WARNING: DISABLING OPPPY MULTIPROCESSING THREADING ON WINDOWS/MAC SYSTEMS")
USE_THREADS = False
NTHREADS = 1

def point_value_1d(data, x_key, value_key, x_value, method='nearest'):
'''
Expand Down
13 changes: 6 additions & 7 deletions opppy/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,23 @@
#----------------------------------------------------------#

import sys
import pickle
import io
import os
import math
import platform
import numpy as np
from multiprocessing import Process, Manager, cpu_count
import pickle
if "linux" in platform.system().lower():
from multiprocessing import Process, Manager, cpu_count
else:
# Protect against multiprocessing fork issue on Windows and Mac
from multiprocess import Process, Manager, cpu_count

from opppy.version import __version__
from opppy.progress import *

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 and Mac
if "linux" not in platform.system().lower():
print("WARNING: DISABLING OPPPY MULTIPROCESSING THREADING ON WINDOWS/MAC SYSTEMS")
USE_THREADS = False
NTHREADS = 1

def append_cycle_data(cycle_data, data, sort_key_string):
'''
Expand Down
13 changes: 6 additions & 7 deletions opppy/tally.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,24 @@
#----------------------------------------------------------#

import sys
import pickle
import io
import os
import math
import platform
import numpy as np
from multiprocessing import Process, Manager, cpu_count
import pickle
if "linux" in platform.system().lower():
from multiprocessing import Process, Manager, cpu_count
else:
# Protect against multiprocessing fork issue on Windows and Mac
from multiprocess import Process, Manager, cpu_count

from opppy.version import __version__
from opppy.progress import *
from opppy.output import *

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 and Mac
if "linux" not in platform.system().lower():
print("WARNING: DISABLING OPPPY MULTIPROCESSING THREADING ON WINDOWS/MAC SYSTEMS")
USE_THREADS = False
NTHREADS = 1

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

0 comments on commit de5c777

Please sign in to comment.