Skip to content

Commit

Permalink
fix python 3.8 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
nlgranger committed Apr 12, 2024
1 parent 69e2075 commit 4ee4599
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
uses: omnilib/ufmt@action-v1
with:
path: seqtools
python-version: "3.11"
python-version: "3.10"

unit-tests:
runs-on: ubuntu-latest
Expand Down
15 changes: 9 additions & 6 deletions seqtools/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def __init__(self, seq, num_workers=0, buffer_size=10, init_fn=None, shm_size=0)
)

@staticmethod
def cleanup(job_queue, workers: list[multiprocessing.Process], monitor):
def cleanup(job_queue, workers, monitor):
for _ in workers:
job_queue.put((-1, -1))
for w in workers:
Expand Down Expand Up @@ -235,21 +235,24 @@ def buffer_callback(buffer):
# serialize it
try:
if shm_slot_start is None:
payload = pkl.dumps(value, protocol=-1)
payload = pkl.dumps(value, protocol=pkl.HIGHEST_PROTOCOL)
else:
buffers_limits.clear()
shm_offset = shm_slot_start
shm_slot_stop = shm_slot_start + shm_slot_size
payload = pkl.dumps(
value, protocol=-1, buffer_callback=buffer_callback
value,
protocol=pkl.HIGHEST_PROTOCOL,
buffer_callback=buffer_callback,
)

except Exception as e: # gracefully recover failed serialization
if success:
success = False
msg = "failed to send item {} to parent process, ".format(
idx
) + "is it picklable? Error message was:\n{}".format(e)
msg = (
f"failed to send item {idx} to parent process, "
+ "is it picklable? Error message was:\n{e}"
)
payload = pkl.dumps(ValueError(msg))
else: # serialize error message because error can't be pickled
payload = pkl.dumps(str(value))
Expand Down

0 comments on commit 4ee4599

Please sign in to comment.