@@ -133,8 +133,8 @@ def get_mapper(self, batch_size=None, chunk_size=None, **kwargs):
133133 """Get a map."""
134134
135135 def _mapper (func , iterable , * func_args , ** func_kwargs ):
136- func = self .mappable_func (func , * func_args , ** func_kwargs )
137- return self ._with_batches (map , func , iterable )
136+ mapped_func = self .mappable_func (func , * func_args , ** func_kwargs )
137+ return self ._with_batches (map , mapped_func , iterable )
138138
139139 return _mapper
140140
@@ -156,10 +156,10 @@ def get_mapper(self, batch_size=None, chunk_size=None, **kwargs):
156156 self ._chunksize_to_kwargs (chunk_size , kwargs , label = "chunksize" )
157157
158158 def _mapper (func , iterable , * func_args , ** func_kwargs ):
159- func = self .mappable_func (func , * func_args , ** func_kwargs )
159+ mapped_func = self .mappable_func (func , * func_args , ** func_kwargs )
160160 return self ._with_batches (
161161 partial (self .pool .imap_unordered , ** kwargs ),
162- func ,
162+ mapped_func ,
163163 iterable ,
164164 )
165165
@@ -195,17 +195,19 @@ def get_mapper(self, batch_size=None, chunk_size=None, **kwargs):
195195 self ._chunksize_to_kwargs (chunk_size , kwargs )
196196
197197 def _mapper (func , iterable , * func_args , ** func_kwargs ):
198- func = self .mappable_func (func , * func_args , ** func_kwargs )
198+ mapped_func = self .mappable_func (func , * func_args , ** func_kwargs )
199199 return self ._with_batches (
200- partial (self .lview .imap , ** kwargs ), func , iterable , batch_size = batch_size
200+ partial (self .lview .imap , ** kwargs ), mapped_func , iterable , batch_size = batch_size
201201 )
202202
203203 return _mapper
204204
205205 def shutdown (self ):
206206 """Remove zmq."""
207- if self . rc is not None : # pragma: no cover
207+ try :
208208 self .rc .close ()
209+ except Exception : # pragma: no cover ; pylint: disable=broad-except
210+ pass
209211
210212
211213class DaskFactory (ParallelFactory ):
@@ -256,13 +258,13 @@ def get_mapper(self, batch_size=None, chunk_size=None, **kwargs):
256258 self ._chunksize_to_kwargs (chunk_size , kwargs , label = "batch_size" )
257259
258260 def _mapper (func , iterable , * func_args , ** func_kwargs ):
259- def _dask_mapper (func , iterable ):
260- futures = self .client .map (func , iterable , ** kwargs )
261+ def _dask_mapper (in_dask_func , iterable ):
262+ futures = self .client .map (in_dask_func , iterable , ** kwargs )
261263 for _future , result in dask .distributed .as_completed (futures , with_results = True ):
262264 yield result
263265
264- func = self .mappable_func (func , * func_args , ** func_kwargs )
265- return self ._with_batches (_dask_mapper , func , iterable , batch_size = batch_size )
266+ mapped_func = self .mappable_func (func , * func_args , ** func_kwargs )
267+ return self ._with_batches (_dask_mapper , mapped_func , iterable , batch_size = batch_size )
266268
267269 return _mapper
268270
0 commit comments