@@ -205,7 +205,9 @@ class _PathIterator(AsyncIterator["Path"]):
205
205
iterator : Iterator [PathLike [str ]]
206
206
207
207
async def __anext__ (self ) -> Path :
208
- nextval = await to_thread .run_sync (next , self .iterator , None , cancellable = True )
208
+ nextval = await to_thread .run_sync (
209
+ next , self .iterator , None , abandon_on_cancel = True
210
+ )
209
211
if nextval is None :
210
212
raise StopAsyncIteration from None
211
213
@@ -386,17 +388,19 @@ async def cwd(cls) -> Path:
386
388
return cls (path )
387
389
388
390
async def exists (self ) -> bool :
389
- return await to_thread .run_sync (self ._path .exists , cancellable = True )
391
+ return await to_thread .run_sync (self ._path .exists , abandon_on_cancel = True )
390
392
391
393
async def expanduser (self ) -> Path :
392
- return Path (await to_thread .run_sync (self ._path .expanduser , cancellable = True ))
394
+ return Path (
395
+ await to_thread .run_sync (self ._path .expanduser , abandon_on_cancel = True )
396
+ )
393
397
394
398
def glob (self , pattern : str ) -> AsyncIterator [Path ]:
395
399
gen = self ._path .glob (pattern )
396
400
return _PathIterator (gen )
397
401
398
402
async def group (self ) -> str :
399
- return await to_thread .run_sync (self ._path .group , cancellable = True )
403
+ return await to_thread .run_sync (self ._path .group , abandon_on_cancel = True )
400
404
401
405
async def hardlink_to (self , target : str | pathlib .Path | Path ) -> None :
402
406
if isinstance (target , Path ):
@@ -413,31 +417,37 @@ def is_absolute(self) -> bool:
413
417
return self ._path .is_absolute ()
414
418
415
419
async def is_block_device (self ) -> bool :
416
- return await to_thread .run_sync (self ._path .is_block_device , cancellable = True )
420
+ return await to_thread .run_sync (
421
+ self ._path .is_block_device , abandon_on_cancel = True
422
+ )
417
423
418
424
async def is_char_device (self ) -> bool :
419
- return await to_thread .run_sync (self ._path .is_char_device , cancellable = True )
425
+ return await to_thread .run_sync (
426
+ self ._path .is_char_device , abandon_on_cancel = True
427
+ )
420
428
421
429
async def is_dir (self ) -> bool :
422
- return await to_thread .run_sync (self ._path .is_dir , cancellable = True )
430
+ return await to_thread .run_sync (self ._path .is_dir , abandon_on_cancel = True )
423
431
424
432
async def is_fifo (self ) -> bool :
425
- return await to_thread .run_sync (self ._path .is_fifo , cancellable = True )
433
+ return await to_thread .run_sync (self ._path .is_fifo , abandon_on_cancel = True )
426
434
427
435
async def is_file (self ) -> bool :
428
- return await to_thread .run_sync (self ._path .is_file , cancellable = True )
436
+ return await to_thread .run_sync (self ._path .is_file , abandon_on_cancel = True )
429
437
430
438
async def is_mount (self ) -> bool :
431
- return await to_thread .run_sync (os .path .ismount , self ._path , cancellable = True )
439
+ return await to_thread .run_sync (
440
+ os .path .ismount , self ._path , abandon_on_cancel = True
441
+ )
432
442
433
443
def is_reserved (self ) -> bool :
434
444
return self ._path .is_reserved ()
435
445
436
446
async def is_socket (self ) -> bool :
437
- return await to_thread .run_sync (self ._path .is_socket , cancellable = True )
447
+ return await to_thread .run_sync (self ._path .is_socket , abandon_on_cancel = True )
438
448
439
449
async def is_symlink (self ) -> bool :
440
- return await to_thread .run_sync (self ._path .is_symlink , cancellable = True )
450
+ return await to_thread .run_sync (self ._path .is_symlink , abandon_on_cancel = True )
441
451
442
452
def iterdir (self ) -> AsyncIterator [Path ]:
443
453
gen = self ._path .iterdir ()
@@ -450,7 +460,7 @@ async def lchmod(self, mode: int) -> None:
450
460
await to_thread .run_sync (self ._path .lchmod , mode )
451
461
452
462
async def lstat (self ) -> os .stat_result :
453
- return await to_thread .run_sync (self ._path .lstat , cancellable = True )
463
+ return await to_thread .run_sync (self ._path .lstat , abandon_on_cancel = True )
454
464
455
465
async def mkdir (
456
466
self , mode : int = 0o777 , parents : bool = False , exist_ok : bool = False
@@ -493,7 +503,7 @@ async def open(
493
503
return AsyncFile (fp )
494
504
495
505
async def owner (self ) -> str :
496
- return await to_thread .run_sync (self ._path .owner , cancellable = True )
506
+ return await to_thread .run_sync (self ._path .owner , abandon_on_cancel = True )
497
507
498
508
async def read_bytes (self ) -> bytes :
499
509
return await to_thread .run_sync (self ._path .read_bytes )
@@ -526,7 +536,7 @@ async def replace(self, target: str | pathlib.PurePath | Path) -> Path:
526
536
527
537
async def resolve (self , strict : bool = False ) -> Path :
528
538
func = partial (self ._path .resolve , strict = strict )
529
- return Path (await to_thread .run_sync (func , cancellable = True ))
539
+ return Path (await to_thread .run_sync (func , abandon_on_cancel = True ))
530
540
531
541
def rglob (self , pattern : str ) -> AsyncIterator [Path ]:
532
542
gen = self ._path .rglob (pattern )
@@ -542,12 +552,12 @@ async def samefile(
542
552
other_path = other_path ._path
543
553
544
554
return await to_thread .run_sync (
545
- self ._path .samefile , other_path , cancellable = True
555
+ self ._path .samefile , other_path , abandon_on_cancel = True
546
556
)
547
557
548
558
async def stat (self , * , follow_symlinks : bool = True ) -> os .stat_result :
549
559
func = partial (os .stat , follow_symlinks = follow_symlinks )
550
- return await to_thread .run_sync (func , self ._path , cancellable = True )
560
+ return await to_thread .run_sync (func , self ._path , abandon_on_cancel = True )
551
561
552
562
async def symlink_to (
553
563
self ,
0 commit comments