Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queues are threadsafe - lists are not! #1

Open
shrewdlogarithm opened this issue May 26, 2023 · 1 comment
Open

Queues are threadsafe - lists are not! #1

shrewdlogarithm opened this issue May 26, 2023 · 1 comment

Comments

@shrewdlogarithm
Copy link

I made a comment on the article you originally posted this in but I thought I'd put this here too.

Whislt queues are - as you say - threadsafe, the array you're holding them in is NOT threadsafe...

Sooner or later you'll see "index out of range" errors - either when reading through (backwards) or deleting array elements...

Adding another exception to "ignore" this is probably fine - another thread just did the work - but it caught-me-out when I moved from the development to a proper 'threaded' webserver (it took many hours to happen - but then happened 10 times in a single day!!)

@MaxHalford
Copy link
Owner

Thanks for pointing this out! I didn't think about this when I wrote this back in 2020. I agree with what @neojaw mentions here, in that a lock should be used. I think that's cleaner than catching exceptions coming from race conditions.

I'll leave this issue open so people have an easier way finding it :)

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

No branches or pull requests

2 participants