Twitter | Pretraživanje | |
James Bennett
Today I learned: Python’s concurrency-safe queue structures have a hard limit of 32,768 items. I totally did not deadlock a piece of code by not paying attention to that, why do you ask?
Reply Retweet Označi sa "sviđa mi se" More
James Bennett 11. ruj
Odgovor korisniku/ci @ubernostrum
And to stave off some questions: I wasn’t paying attention to it because the documentation states that if “maxsize is less than or equal to zero, the queue size is infinite”. I did not in fact assume “infinite”. But did assume > 32,768. Which turned out to be naïve.
Reply Retweet Označi sa "sviđa mi se"
James Bennett 11. ruj
Odgovor korisniku/ci @ubernostrum
Debugging it was a fun story, too. At first I thought it was something else stalling out (since all the failures happened at suspicious powers of 2). Eventually isolated just the queue setup and saw it start to block put() at 32,768 items.
Reply Retweet Označi sa "sviđa mi se"
James Bennett 11. ruj
Odgovor korisniku/ci @ubernostrum
So then I tried creating a queue with a higher maxsize, and got an immediate exception saying that’s not allowed. Turns out to be a hard-coded limit. Perhaps this should be documented better.
Reply Retweet Označi sa "sviđa mi se"
James Bennett 11. ruj
Odgovor korisniku/ci @ubernostrum
(it’s not entirely Python’s fault, since this is actually handed off to system-specific non-Python semaphore implementations, and that’s where the hard-coded limit actually lives, but still, could be documented better)
Reply Retweet Označi sa "sviđa mi se"
James Bennett 11. ruj
Odgovor korisniku/ci @ubernostrum
And to clarify a bit: it’s 32,768 on my system. May be different on yours. The actual limit is your system’s SEM_VALUE_MAX.
Reply Retweet Označi sa "sviđa mi se"
Chris Samp 12. ruj
Odgovor korisniku/ci @ubernostrum
So THAT’S why my first programming teacher made me learn the first 16 powers of two by heart.
Reply Retweet Označi sa "sviđa mi se"
Diane Chen 12. ruj
Odgovor korisniku/ci @cgsamp @ubernostrum
When I was in High school (which was a looooong time ago), one of our teachers had us chanting "two to the tenth is ten twenty four" and insisted we would need to know that. He was right!
Reply Retweet Označi sa "sviđa mi se"