Example #1
0
def mp_test():
    qu = multiprocessing.Manager().Queue()
    startTime = timeit.default_timer()
    with futurist.ProcessPoolExecutor(max_workers=8) as executors:
        futures = [executors.submit(compute, qu) for _ in range(8)]
        results = [f.result() for f in futures]

        print('result : {}'.format(qu.get()))
        resource_info(startTime)
Example #2
0
 def test_process_executor_creation(self):
     with futurist.ProcessPoolExecutor(1) as e:
         eng = self._create_engine(executor=e)
         self.assertIsInstance(eng._task_executor,
                               process_executor.ParallelProcessTaskExecutor)
Example #3
0
 def _create_executor(self, max_workers=None):
     return futurist.ProcessPoolExecutor(max_workers=max_workers)
Example #4
0
    executor = futurist.GreenThreadPoolExecutor()
except RuntimeError:
    # No eventlet currently active, skip running with it...
    pass
else:
    print("-- Running in parallel using eventlet --")
    with executor:
        e = engines.load(song, executor=executor, engine='parallel')
        e.run()


# Run in parallel using real threads...
with futurist.ThreadPoolExecutor(max_workers=1) as executor:
    print("-- Running in parallel using threads --")
    e = engines.load(song, executor=executor, engine='parallel')
    e.run()


# Run in parallel using external processes...
with futurist.ProcessPoolExecutor(max_workers=1) as executor:
    print("-- Running in parallel using processes --")
    e = engines.load(song, executor=executor, engine='parallel')
    e.run()


# Run serially (aka, if the workflow could have been ran in parallel, it will
# not be when ran in this mode)...
print("-- Running serially --")
e = engines.load(song, engine='serial')
e.run()
import time

import futurist


def delayed_func():
    print('started')
    time.sleep(3)
    print('done')
    # return "hello"


e = futurist.ProcessPoolExecutor()
fut = e.submit(delayed_func)
#print(fut.result())
print('Hello')
e.shutdown()