# Path: pydatajson/threading_helper.py
# def apply_threading(l, function, cant_threads, **kwargs):
#     if cant_threads == 1:
#         return [function(x, **kwargs) for x in l]
#     pool = ThreadPool(processes=cant_threads)
#     results = pool.map(function, l)
#     pool.close()
#     pool.join()
#     return results


from unittest import TestCase
from pydatajson.threading_helper import apply_threading
# -*- coding: utf-8 -*-



class ThreadingTests(TestCase):

    def test_threading(self):
        elements = [1, 2, 3, 4]

        def function(x):
            return x ** 2


# Path: pydatajson/threading_helper.py
# def apply_threading(l, function, cant_threads, **kwargs):
#     if cant_threads == 1:
#         return [function(x, **kwargs) for x in l]
#     pool = ThreadPool(processes=cant_threads)
#     results = pool.map(function, l)
#     pool.close()
#     pool.join()
#     return results


# Path: tests/test_threading.py
from unittest import TestCase
from pydatajson.threading_helper import apply_threading

# -*- coding: utf-8 -*-



class ThreadingTests(TestCase):

    def test_threading(self):
        elements = [1, 2, 3, 4]

        def function(x):
            return x ** 2


        result = apply_threading(elements, function, 3)