Skip to content

Commit

Permalink
Pass str dtype for use_str case
Browse files Browse the repository at this point in the history
  • Loading branch information
goodboy committed Mar 15, 2023
1 parent f8663d9 commit 2b50a94
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 10 additions & 4 deletions tests/test_shm.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ async def child_read_shm_list(
) -> None:

# attach in child
shml = attach_shm_list(key=shm_key)
shml = attach_shm_list(
key=shm_key,
# dtype=str if use_str else float,
)
await ctx.started(shml.key)

async with ctx.open_stream() as stream:
Expand All @@ -92,7 +95,9 @@ async def child_read_shm_list(


@pytest.mark.parametrize(
'use_str', [False, True],
'use_str',
[False, True],
ids=lambda i: f'use_str_values={i}',
)
@pytest.mark.parametrize(
'frame_size',
Expand All @@ -106,7 +111,7 @@ def test_parent_writer_child_reader(

async def main():
async with tractor.open_nursery(
debug_mode=True,
# debug_mode=True,
) as an:

portal = await an.start_actor(
Expand All @@ -121,6 +126,7 @@ async def main():
shml = open_shm_list(
key=key,
size=seq_size,
dtype=str if use_str else float,
readonly=False,
)

Expand All @@ -143,7 +149,7 @@ async def main():
if use_str:
val = str(val)

print(f'(parent): writing {val}')
# print(f'(parent): writing {val}')
shml[i] = val

# only on frame fills do we
Expand Down
2 changes: 0 additions & 2 deletions tractor/_shm.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,6 @@ def flush(self) -> None:


def open_shm_ndarray(

key: Optional[str] = None,
size: int = int(2 ** 10),
dtype: np.dtype | None = None,
Expand Down Expand Up @@ -799,7 +798,6 @@ def open_shm_list(
None: None,
}[dtype]
sequence = [default] * size
# sequence = [0.] * size

shml = ShmList(
sequence=sequence,
Expand Down

0 comments on commit 2b50a94

Please sign in to comment.