Skip to content

Conversation

@crusaderky
Copy link
Collaborator

@crusaderky crusaderky commented Mar 21, 2023

zict.File is now almost fully thread-safe, with the only caveat that you can't call __setitem__ on the same key at the same time from two different threads. Crucially for dask/distributed#4424, you can now delete a key from the main thread while the same key is being either read or written from an offloaded thread.

@crusaderky crusaderky self-assigned this Mar 21, 2023
@crusaderky crusaderky changed the title Enhance thread-safety in File Enhanced thread-safety in zict.File Mar 21, 2023
assert f1.result() > 100
assert f2.result() > 100

assert not z
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried writing a test for concurrency on the same key, with a single producer/destroyer and multiple consumers/destroyers, but I gave up. The reason is that the only way a consumer can grab a key while it's being overwritten over and over is that it accidentally hits the spot between iterations of __setitem__, which is extremely hard.

@crusaderky crusaderky marked this pull request as ready for review March 22, 2023 13:17
@crusaderky crusaderky mentioned this pull request Mar 22, 2023
Copy link

@milesgranger milesgranger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@crusaderky crusaderky merged commit 6b97268 into dask:main Mar 22, 2023
@crusaderky crusaderky deleted the File_threadsafe branch March 22, 2023 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Asynchronous Disk Access in Workers

2 participants