Skip to content

Commit

Permalink
Merge pull request #195 from alpacahq/change_can_trade_check
Browse files Browse the repository at this point in the history
Process pool should be initiated once
  • Loading branch information
Shlomi Kushchi committed Sep 18, 2020
2 parents f1f5430 + f3ab4ac commit 231d994
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ RUN wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz && \
make install
RUN rm -R ta-lib ta-lib-0.4.0-src.tar.gz

RUN pip install pylivetrader==0.5.0
RUN pip install pylivetrader==0.5.1
2 changes: 1 addition & 1 deletion pylivetrader/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

VERSION = '0.5.0'
VERSION = '0.5.1'
9 changes: 7 additions & 2 deletions pylivetrader/misc/parallel_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import os
from multiprocessing import Pool

PROCESS_POOL = None


def _get_default_workers():
workers = os.environ.get('PYLT_NUM_WORKERS')
Expand Down Expand Up @@ -55,8 +57,11 @@ def parallelize_with_multi_process(mapfunc, workers=10):
Return: func(args_list) => list[func[arg]]
"""
global PROCESS_POOL
if not PROCESS_POOL:
PROCESS_POOL = Pool(workers)

def wrapper(args_list):
with Pool(workers) as pool:
return pool.map(mapfunc, args_list)
return PROCESS_POOL.map(mapfunc, args_list)

return wrapper

0 comments on commit 231d994

Please sign in to comment.