shared_memory
shared_memory copied to clipboard
"Can't create shared memory error" for Python/Matlab on Windows
Hi, this looks like an interesting library and have tried to get it to run on Windows (10 Pro) for Python and Matlab but consistently get the same "Can't create shared memory error".
Python 3.9.5 (default, May 18 2021, 14:42:02) [MSC v.1916 64 bit (AMD64)]
---------------------------------------------------------------------------
SharedMemoryLibraryError Traceback (most recent call last)
File shared_memory\test.py:12, in <module>
9 d = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
11 # Share
---> 12 set_shared_memory_data(d)
14 # Receive
15 data = get_shared_memory_data()
File shared_memory\python\shared_memory.py:458, in set_shared_memory_data(data)
456 _check_library_error(_c_library_set_shared_memory_data_signed_16(data, temp_dims, temp_rank))
457 elif data_type == np.int32:
--> 458 _check_library_error(_c_library_set_shared_memory_data_signed_32(data, temp_dims, temp_rank))
459 elif data_type == np.int64:
460 _check_library_error(_c_library_set_shared_memory_data_signed_64(data, temp_dims, temp_rank))
File shared_memory\python\shared_memory.py:243, in _check_library_error(value)
241 return value
242 else:
--> 243 raise SharedMemoryLibraryError(value)
SharedMemoryLibraryError: Can't create shared memory
I have also successfully recompiled the library and the test suite seems to run fine. Is there a recommended way how to debug this issue?
Thanks for bringing up this issue. The core library was written in Rust based on a crate called shared_memory. If for any reason the crate couldn't create a link, you'll get -4 or SharedMemoryLibraryError: Can't create shared memory in python.
For debugging, since you can compile the library, go to the rust > src > lib.rs > general > impl SharedMemoryInterface for Shmem > new() > let mut shared_memory = ... and replace it with the following code:
Err(temp) => {
println!("[Rust]: {}", temp);
return CAN_NOT_CREATE_SHARED_MEMORY_ERROR;
}
Now compile it and replace it in the project. If you get an error for creating the shared memory in python, you'll see something like this which is generated by the underlying library:
[Rust]: Creating the link file failed, The system cannot find the path specified. (os error 3)
Traceback (most recent call last):
...
Remember this message will not be printed in all interfaces.
Thanks for the response, very odd, I keep getting
[Rust]: Creating the link file failed, Access is denied. (os error 5)
even though just using a public folder, and also trying running python in administrator shell so permission should not be an issue.
I am getting the same error. Is there a solution?
[Rust]: Creating the link file failed, Access is denied. (os error 5)