12
12
def _evolve_func_mp_pool (ser_algo_pop ):
13
13
# The evolve function that is actually run from the separate processes
14
14
# in mp_island (when using the pool).
15
- has_dill = False
16
- try :
17
- import dill
18
-
19
- has_dill = True
20
- except ImportError :
21
- pass
22
- if has_dill :
23
- from dill import dumps , loads
24
- else :
25
- from pickle import dumps , loads
15
+ from pickle import dumps , loads
16
+
26
17
algo , pop = loads (ser_algo_pop )
27
18
new_pop = algo .evolve (pop )
28
19
return dumps ((algo , new_pop ))
@@ -44,17 +35,8 @@ def _evolve_func_mp_pipe(conn, ser_algo_pop):
44
35
# of a child process happens in a separate thread and Python disallows messing
45
36
# with signal handlers from a thread different from the main one :(
46
37
with _temp_disable_sigint ():
47
- has_dill = False
48
- try :
49
- import dill
38
+ from pickle import dumps , loads
50
39
51
- has_dill = True
52
- except ImportError :
53
- pass
54
- if has_dill :
55
- from dill import dumps , loads
56
- else :
57
- from pickle import dumps , loads
58
40
try :
59
41
algo , pop = loads (ser_algo_pop )
60
42
new_pop = algo .evolve (pop )
@@ -227,17 +209,8 @@ def run_evolve(self, algo, pop):
227
209
# that if there are serialization errors, we catch them early here rather
228
210
# than failing in the bootstrap phase of the remote process, which
229
211
# can lead to hangups.
230
- has_dill = False
231
- try :
232
- import dill
212
+ from pickle import dumps , loads
233
213
234
- has_dill = True
235
- except ImportError :
236
- pass
237
- if has_dill :
238
- from dill import dumps , loads
239
- else :
240
- from pickle import dumps , loads
241
214
ser_algo_pop = dumps ((algo , pop ))
242
215
243
216
if self ._use_pool :
@@ -470,17 +443,8 @@ def shutdown_pool():
470
443
def _evolve_func_ipy (ser_algo_pop ):
471
444
# The evolve function that is actually run from the separate processes
472
445
# in ipyparallel_island.
473
- has_dill = False
474
- try :
475
- import dill
476
-
477
- has_dill = True
478
- except ImportError :
479
- pass
480
- if has_dill :
481
- from dill import dumps , loads
482
- else :
483
- from pickle import dumps , loads
446
+ from pickle import dumps , loads
447
+
484
448
algo , pop = loads (ser_algo_pop )
485
449
new_pop = algo .evolve (pop )
486
450
return dumps ((algo , new_pop ))
@@ -613,17 +577,7 @@ def run_evolve(self, algo, pop):
613
577
# serialization errors early.
614
578
from ._ipyparallel_utils import _make_ipyparallel_view
615
579
616
- has_dill = False
617
- try :
618
- import dill
619
-
620
- has_dill = True
621
- except ImportError :
622
- pass
623
- if has_dill :
624
- from dill import dumps , loads
625
- else :
626
- from pickle import dumps , loads
580
+ from pickle import dumps , loads
627
581
628
582
ser_algo_pop = dumps ((algo , pop ))
629
583
with ipyparallel_island ._view_lock :
0 commit comments