Skip to content

Commit

Permalink
Merge branch 'master' of github.com:semiversus/python-broqer
Browse files Browse the repository at this point in the history
  • Loading branch information
semiversus committed Sep 15, 2018
2 parents 728c5bf + 9f403af commit 48b1e7d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
9 changes: 1 addition & 8 deletions broqer/op/map_.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@
from .operator import Operator, build_operator


def _partial(function: Callable, *args, **kwargs) -> Callable:
""" apply partial when args and kwargs are defined """
if args or kwargs:
return partial(function, *args, **kwargs)
return function


class Map(Operator):
""" Apply ``map_func(*args, value, **kwargs)`` to each emitted value.
:param publisher: source publisher
Expand All @@ -65,7 +58,7 @@ def __init__(self, publisher: Publisher, map_func: Callable[[Any], Any],
"""

Operator.__init__(self, publisher)
self._map_func = _partial(map_func, *args, **kwargs)
self._map_func = partial(map_func, *args, **kwargs)
self._unpack = unpack

def get(self):
Expand Down
4 changes: 2 additions & 2 deletions broqer/op/map_threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@
"""
import asyncio
from concurrent.futures import ThreadPoolExecutor
from functools import partial

from broqer import Publisher, default_error_handler

from .operator import build_operator
from .map_async import MapAsync, MODE
from .map_ import _partial


class MapThreaded(MapAsync):
Expand All @@ -115,7 +115,7 @@ def __init__(self, publisher: Publisher, map_func, *args,
MapAsync.__init__(self, publisher, self._thread_coro, mode=mode,
error_callback=error_callback, unpack=unpack)

self._map_func = _partial(map_func, *args, **kwargs)
self._map_func = partial(map_func, *args, **kwargs)
self._loop = loop or asyncio.get_event_loop()
self._executor = ThreadPoolExecutor()

Expand Down

0 comments on commit 48b1e7d

Please sign in to comment.