|
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | 15 | import os |
| 16 | +import shutil |
16 | 17 | import sys |
17 | 18 | import tempfile |
18 | 19 | from typing import List |
@@ -202,27 +203,31 @@ async def test_copy_via_fileobjects(): |
202 | 203 | subprocess_start_method=start_method, |
203 | 204 | ) |
204 | 205 |
|
205 | | - with tempfile.TemporaryDirectory() as d: |
206 | | - async with pool: |
207 | | - ctx = get_context() |
208 | | - |
209 | | - # actor on main pool |
210 | | - actor_ref1 = await ctx.create_actor( |
211 | | - FileobjTransferActor, |
212 | | - uid="test-1", |
213 | | - address=pool.external_address, |
214 | | - allocate_strategy=ProcessIndex(1), |
215 | | - ) |
216 | | - actor_ref2 = await ctx.create_actor( |
217 | | - FileobjTransferActor, |
218 | | - uid="test-2", |
219 | | - address=pool.external_address, |
220 | | - allocate_strategy=ProcessIndex(2), |
221 | | - ) |
222 | | - sizes = [10 * 1024**2, 3 * 1024**2] |
223 | | - names = [] |
224 | | - for _ in range(2 * len(sizes)): |
225 | | - _, p = tempfile.mkstemp(dir=d) |
226 | | - names.append(p) |
227 | | - |
228 | | - await actor_ref1.copy_data(actor_ref2, names[::2], names[1::2], sizes=sizes) |
| 206 | + d = tempfile.mkdtemp() |
| 207 | + async with pool: |
| 208 | + ctx = get_context() |
| 209 | + |
| 210 | + # actor on main pool |
| 211 | + actor_ref1 = await ctx.create_actor( |
| 212 | + FileobjTransferActor, |
| 213 | + uid="test-1", |
| 214 | + address=pool.external_address, |
| 215 | + allocate_strategy=ProcessIndex(1), |
| 216 | + ) |
| 217 | + actor_ref2 = await ctx.create_actor( |
| 218 | + FileobjTransferActor, |
| 219 | + uid="test-2", |
| 220 | + address=pool.external_address, |
| 221 | + allocate_strategy=ProcessIndex(2), |
| 222 | + ) |
| 223 | + sizes = [10 * 1024**2, 3 * 1024**2] |
| 224 | + names = [] |
| 225 | + for _ in range(2 * len(sizes)): |
| 226 | + _, p = tempfile.mkstemp(dir=d) |
| 227 | + names.append(p) |
| 228 | + |
| 229 | + await actor_ref1.copy_data(actor_ref2, names[::2], names[1::2], sizes=sizes) |
| 230 | + try: |
| 231 | + shutil.rmtree(d) |
| 232 | + except PermissionError: |
| 233 | + pass |
0 commit comments