@@ -30,6 +30,9 @@ def wait_for_errors(error_type, num_errors, timeout=10):
30
30
31
31
32
32
class TaskStatusTest (unittest .TestCase ):
33
+ def tearDown (self ):
34
+ ray .worker .cleanup ()
35
+
33
36
def testFailedTask (self ):
34
37
reload (test_functions )
35
38
ray .init (num_workers = 3 , driver_mode = ray .SILENT_MODE )
@@ -61,8 +64,6 @@ def testFailedTask(self):
61
64
# ray.get should throw an exception.
62
65
self .assertTrue (False )
63
66
64
- ray .worker .cleanup ()
65
-
66
67
def testFailImportingRemoteFunction (self ):
67
68
ray .init (num_workers = 2 , driver_mode = ray .SILENT_MODE )
68
69
@@ -100,7 +101,6 @@ def g():
100
101
101
102
# Clean up the junk we added to sys.path.
102
103
sys .path .pop (- 1 )
103
- ray .worker .cleanup ()
104
104
105
105
def testFailedFunctionToRun (self ):
106
106
ray .init (num_workers = 2 , driver_mode = ray .SILENT_MODE )
@@ -117,8 +117,6 @@ def f(worker):
117
117
self .assertIn (b"Function to run failed." ,
118
118
ray .error_info ()[1 ][b"message" ])
119
119
120
- ray .worker .cleanup ()
121
-
122
120
def testFailImportingActor (self ):
123
121
ray .init (num_workers = 2 , driver_mode = ray .SILENT_MODE )
124
122
@@ -178,10 +176,11 @@ def get_val(self):
178
176
179
177
# Clean up the junk we added to sys.path.
180
178
sys .path .pop (- 1 )
181
- ray .worker .cleanup ()
182
179
183
180
184
181
class ActorTest (unittest .TestCase ):
182
+ def tearDown (self ):
183
+ ray .worker .cleanup ()
185
184
186
185
def testFailedActorInit (self ):
187
186
ray .init (num_workers = 0 , driver_mode = ray .SILENT_MODE )
@@ -215,8 +214,6 @@ def fail_method(self):
215
214
self .assertIn (error_message2 ,
216
215
ray .error_info ()[1 ][b"message" ].decode ("ascii" ))
217
216
218
- ray .worker .cleanup ()
219
-
220
217
def testIncorrectMethodCalls (self ):
221
218
ray .init (num_workers = 0 , driver_mode = ray .SILENT_MODE )
222
219
@@ -254,10 +251,10 @@ def get_val(self, x):
254
251
with self .assertRaises (AttributeError ):
255
252
a .nonexistent_method .remote ()
256
253
257
- ray .worker .cleanup ()
258
-
259
254
260
255
class WorkerDeath (unittest .TestCase ):
256
+ def tearDown (self ):
257
+ ray .worker .cleanup ()
261
258
262
259
def testWorkerRaisingException (self ):
263
260
ray .init (num_workers = 1 , driver_mode = ray .SILENT_MODE )
@@ -290,8 +287,6 @@ def f():
290
287
self .assertIn ("A worker died or was killed while executing a task." ,
291
288
ray .error_info ()[0 ][b"message" ].decode ("ascii" ))
292
289
293
- ray .worker .cleanup ()
294
-
295
290
def testActorWorkerDying (self ):
296
291
ray .init (num_workers = 0 , driver_mode = ray .SILENT_MODE )
297
292
@@ -310,8 +305,6 @@ def consume(x):
310
305
self .assertRaises (Exception , lambda : ray .get (consume .remote (obj )))
311
306
wait_for_errors (b"worker_died" , 1 )
312
307
313
- ray .worker .cleanup ()
314
-
315
308
def testActorWorkerDyingFutureTasks (self ):
316
309
ray .init (num_workers = 0 , driver_mode = ray .SILENT_MODE )
317
310
@@ -334,8 +327,6 @@ def sleep(self):
334
327
335
328
wait_for_errors (b"worker_died" , 1 )
336
329
337
- ray .worker .cleanup ()
338
-
339
330
def testActorWorkerDyingNothingInProgress (self ):
340
331
ray .init (num_workers = 0 , driver_mode = ray .SILENT_MODE )
341
332
@@ -351,10 +342,10 @@ def getpid(self):
351
342
task2 = a .getpid .remote ()
352
343
self .assertRaises (Exception , lambda : ray .get (task2 ))
353
344
354
- ray .worker .cleanup ()
355
-
356
345
357
346
class PutErrorTest (unittest .TestCase ):
347
+ def tearDown (self ):
348
+ ray .worker .cleanup ()
358
349
359
350
def testPutError1 (self ):
360
351
store_size = 10 ** 6
@@ -400,8 +391,6 @@ def put_arg_task():
400
391
# Make sure we receive the correct error message.
401
392
wait_for_errors (b"put_reconstruction" , 1 )
402
393
403
- ray .worker .cleanup ()
404
-
405
394
def testPutError2 (self ):
406
395
# This is the same as the previous test, but it calls ray.put directly.
407
396
store_size = 10 ** 6
@@ -446,10 +435,10 @@ def put_task():
446
435
# Make sure we receive the correct error message.
447
436
wait_for_errors (b"put_reconstruction" , 1 )
448
437
449
- ray .worker .cleanup ()
450
-
451
438
452
439
class ConfigurationTest (unittest .TestCase ):
440
+ def tearDown (self ):
441
+ ray .worker .cleanup ()
453
442
454
443
def testVersionMismatch (self ):
455
444
import cloudpickle
@@ -461,7 +450,6 @@ def testVersionMismatch(self):
461
450
wait_for_errors (b"version_mismatch" , 1 )
462
451
463
452
cloudpickle .__version__ = cloudpickle_version
464
- ray .worker .cleanup ()
465
453
466
454
467
455
if __name__ == "__main__" :
0 commit comments