fix shm path test on macos (#2357)

AttributeError: 'PosixPath' object has no attribute 'startswith'
This commit is contained in:
chenyu 2023-11-18 17:37:42 -05:00 committed by GitHub
commit 0443cbfbb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,7 +14,7 @@ class RawDiskBuffer(RawBufferMapped):
self.offset = offset # this is an offset in bytes
assert device is not None or buf is not None, "disk tensor needs a path or a buf"
if device is not None:
if device.startswith("shm:"):
if str(device).startswith("shm:"):
if OSX:
with open(f"/tmp/shm_{device[4:]}", "w+b") as f:
f.truncate(size * dtype.itemsize)