Skip to content

Commit adcc5f3

Browse files
committed
BUG: Fix SharedMemory references on Windows
1 parent c712909 commit adcc5f3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

backtesting/backtesting.py

+3
Original file line numberDiff line numberDiff line change
@@ -1508,12 +1508,15 @@ def _batch(seq):
15081508
with mp.Pool() as pool, \
15091509
SharedMemoryManager() as smm:
15101510

1511+
shm_refs = [] # https://stackoverflow.com/questions/74193377/filenotfounderror-when-passing-a-shared-memory-to-a-new-process#comment130999060_74194875 # noqa: E501
1512+
15111513
def arr2shm(vals):
15121514
nonlocal smm
15131515
shm = smm.SharedMemory(size=vals.nbytes)
15141516
buf = np.ndarray(vals.shape, dtype=vals.dtype, buffer=shm.buf)
15151517
buf[:] = vals[:] # Copy into shared memory
15161518
assert vals.ndim == 1, (vals.ndim, vals.shape, vals)
1519+
shm_refs.append(shm)
15171520
return shm.name, vals.shape, vals.dtype
15181521

15191522
data_shm = tuple((

0 commit comments

Comments
 (0)