@@ -58,8 +58,6 @@ class WolframEvaluatorPool(WolframAsyncEvaluator):
5858 Set `load_factor` to specify how many workloads are queued per kernel before a new evaluation becomes a blocking
5959 operation. Values below or equal to 0 mean an infinite queue size.
6060
61- Set `loop` to the event loop to use.
62-
6361 `kwargs` are passed to :class:`~wolframclient.evaluation.WolframLanguageAsyncSession` during initialization.
6462 """
6563
@@ -68,14 +66,13 @@ def __init__(
6866 async_evaluators = None ,
6967 poolsize = 4 ,
7068 load_factor = 0 ,
71- loop = None ,
7269 async_language_session_class = WolframLanguageAsyncSession ,
7370 ** kwargs
7471 ):
75- super ().__init__ (loop )
72+ super ().__init__ ()
7673 if poolsize <= 0 :
7774 raise ValueError ("Invalid pool size value %i. Expecting a positive integer." % poolsize )
78- self ._queue = asyncio .Queue (load_factor * poolsize , loop = self . _loop )
75+ self ._queue = asyncio .Queue (load_factor * poolsize )
7976 self .async_language_session_class = async_language_session_class
8077 self ._evaluators = set ()
8178 if async_evaluators is None or isinstance (async_evaluators , six .string_types ):
@@ -98,7 +95,7 @@ def __init__(
9895 def _add_evaluator (self , evaluator , ** kwargs ):
9996 if evaluator is None or isinstance (evaluator , six .string_types ):
10097 self ._evaluators .add (
101- self .async_language_session_class (kernel = evaluator , loop = self . _loop , ** kwargs )
98+ self .async_language_session_class (kernel = evaluator , ** kwargs )
10299 )
103100 elif isinstance (evaluator , WolframAsyncEvaluator ):
104101 if evaluator in self ._evaluators :
@@ -196,11 +193,10 @@ async def start(self):
196193 self .stopped = False
197194 # keep track of the init tasks. We have to wait before terminating.
198195 self ._kernel_start_tasks = {
199- (asyncio .ensure_future (self ._async_start_kernel (kernel ), loop = self ._loop ))
200- for kernel in self ._evaluators
196+ asyncio .ensure_future (self ._async_start_kernel (kernel )) for kernel in self ._evaluators
201197 }
202198 # uninitialized kernels are removed if they failed to start
203- # if they do start, the task (the loop) is added to _kernel_evaluation_loop_tasks.
199+ # if they do start, the task is added to _kernel_evaluation_loop_tasks.
204200 # we need at least one working kernel.
205201 # we also need to keep track of start kernel tasks in case of early termination.
206202 while len (self ._kernel_evaluation_loop_tasks ) == 0 :
@@ -228,15 +224,15 @@ async def stop(self):
228224 for _ in range (len (self ._kernel_evaluation_loop_tasks )):
229225 await self ._queue .put (None )
230226 # wait for loop to finish before terminating the kernels
231- await asyncio .wait (self ._kernel_evaluation_loop_tasks , loop = self . _loop )
227+ await asyncio .wait (self ._kernel_evaluation_loop_tasks )
232228 except CancelledError :
233229 pass
234230 except Exception as e :
235231 logger .warning ("Exception raised while terminating loop: %s" , e )
236232 # terminate the kernel instances, if any started.
237233 tasks = {asyncio .create_task (kernel .stop ()) for kernel in self ._evaluators }
238234 # `wait` raises the first exception, but wait for all tasks to finish.
239- await asyncio .wait (tasks , loop = self . _loop )
235+ await asyncio .wait (tasks )
240236
241237 async def terminate (self ):
242238 await self .stop ()
@@ -253,17 +249,17 @@ async def _put_evaluation_task(self, future, func, expr, **kwargs):
253249 self .eval_count += 1
254250
255251 async def evaluate (self , expr , ** kwargs ):
256- future = asyncio .Future (loop = self . _loop )
252+ future = asyncio .Future ()
257253 await self ._put_evaluation_task (future , "evaluate" , expr , ** kwargs )
258254 return await future
259255
260256 async def evaluate_wxf (self , expr , ** kwargs ):
261- future = asyncio .Future (loop = self . _loop )
257+ future = asyncio .Future ()
262258 await self ._put_evaluation_task (future , "evaluate_wxf" , expr , ** kwargs )
263259 return await future
264260
265261 async def evaluate_wrap (self , expr , ** kwargs ):
266- future = asyncio .Future (loop = self . _loop )
262+ future = asyncio .Future ()
267263 await self ._put_evaluation_task (future , "evaluate_wrap" , expr , ** kwargs )
268264 return await future
269265
@@ -283,7 +279,7 @@ def __len__(self):
283279 return len (self ._kernel_evaluation_loop_tasks )
284280
285281
286- def parallel_evaluate (expressions , evaluator_spec = None , max_evaluators = 4 , loop = None ):
282+ def parallel_evaluate (expressions , evaluator_spec = None , max_evaluators = 4 ):
287283 """ Start a kernel pool and evaluate the expressions in parallel.
288284
289285 The pool is created with the value of `evaluator_spec`. The pool is automatically stopped when it is no longer
0 commit comments