Skip to content

Commit

Permalink
cleanup and partial revert of using spawn for macos exports. Using fo…
Browse files Browse the repository at this point in the history
…rk is ok, the issue was a different bug.
  • Loading branch information
mkassner committed Apr 20, 2017
1 parent 8a1f803 commit 9322601
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 29 deletions.
22 changes: 11 additions & 11 deletions pupil_src/player/batch_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
sys.path.append(os.path.join(pupil_base_dir, 'pupil_src', 'shared_modules'))

from plugin import Plugin
from video_export_launcher import Export_Process, Value, cpu_count
from video_export_launcher import mp, Export_Process

from exporter import export
from player_methods import is_pupil_rec_dir
Expand Down Expand Up @@ -67,8 +67,8 @@ def __init__(self, g_pool):
self.source_dir = default_path

self.run = False
self.workers = [None for x in range(cpu_count())]
logger.info("Using a maximum of {} CPUs to process visualizations in parallel...".format(cpu_count()))
self.workers = [None for x in range(mp.cpu_count())]
logger.info("Using a maximum of {} CPUs to process visualizations in parallel...".format(mp.cpu_count()))

def unset_alive(self):
self.alive = False
Expand Down Expand Up @@ -142,9 +142,9 @@ def add_exports(self):
outfiles = set()
for d in self.new_exports:
logger.debug("Adding new export.")
should_terminate = Value(c_bool, False)
frames_to_export = Value(c_int, 0)
current_frame = Value(c_int, 0)
should_terminate = mp.Value(c_bool, False)
frames_to_export = mp.Value(c_int, 0)
current_frame = mp.Value(c_int, 0)
start_frame = None
end_frame = None
export_dir = d
Expand Down Expand Up @@ -295,17 +295,17 @@ class Temp(object):

recording_dirs = get_recording_dirs(data_dir)
# start multiprocessing engine
n_cpu = cpu_count()
n_cpu = mp.cpu_count()
logger.info("Using a maximum of {} CPUs to process visualizations in parallel...".format(n_cpu))

jobs = []
outfiles = set()
for d in recording_dirs:
j = Temp()
logger.info("Adding new export: {}".format(d))
j.should_terminate = Value(c_bool, 0)
j.frames_to_export = Value(c_int, 0)
j.current_frame = Value(c_int, 0)
j.should_terminate = mp.Value(c_bool, 0)
j.frames_to_export = mp.Value(c_int, 0)
j.current_frame = mp.Value(c_int, 0)
j.data_dir = d
j.user_dir = None
j.start_frame = None
Expand All @@ -330,7 +330,7 @@ class Temp(object):
j.out_file_path = None

j.args = (j.should_terminate, j.frames_to_export, j.current_frame, j.data_dir, j.user_dir,
j.start_frame, j.end_frame, j.plugin_initializers, j.out_file_path)
j.start_frame, j.end_frame, j.plugin_initializers, j.out_file_path,None)
jobs.append(j)

todo = jobs[:]
Expand Down
20 changes: 2 additions & 18 deletions pupil_src/player/video_export_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,13 @@
'''

from plugin import Plugin
import numpy as np
import os,sys
import platform
import os
import time
import multiprocessing as mp
from pyglui import ui
import logging
logger = logging.getLogger(__name__)

from ctypes import c_bool, c_int
import multiprocessing as mp
from multiprocessing import Value, cpu_count

#threading and processing
if platform.system() in ('Darwin'):
from multiprocessing import get_context
mp = get_context('spawn')
Value = mp.Value
cpu_count = mp.cpu_count
else:
import multiprocessing as mp
from multiprocessing import Value, cpu_count


from exporter import export

class Export_Process(mp.Process):
Expand Down

0 comments on commit 9322601

Please sign in to comment.