This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author altuezi
Recipients altuezi, davin, josh.r
Date 2016-12-16.17:27:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1481909245.27.0.0644123123684.issue28982@psf.upfronthosting.co.za>
In-reply-to
Content
So, the code handles timeout = 0 on systems where time.time() returns an int. Look at the following snippet and consider 2 assumptions: (1) time.time() returns an int, and (2) self._rlock.acquire call takes less than a second

            if block:
                deadline = time.time() + timeout
            if not self._rlock.acquire(block, timeout):
                raise Empty
            try:
                if block:
                    timeout = deadline - time.time()
                    if timeout < 0 or not self._poll(timeout):
                        raise Empty


The problem for the timeout = 0 case happens on systems where time.time() returns a floating point number and the acquire lock takes enough time to cause a diff in time.time() result between the deadline instantiation line and the timeout update line.

Given that, especially the `if timeout < 0 ...` line, I thought it may have been in the original intent for the function to handle 0 timeout when block truthy.

That side, the whole concept of having a separate block bool arg in the first place is a tad strange for me. Isn't it a bit redundant?

Why not just follow the underlying poll/select timeout arg logic as follows:

timeout = None, block indefinitely
timeout <= 0, non-block
timeout > 0, block timeout length

We could simplify this interaction by just removing that block arg all together. Not that I'm asking to do that here though, but maybe in the future?

If we go down the suggested error-raising path though, I would ask that the error not be queue.Empty -- which is misleading.
History
Date User Action Args
2016-12-16 17:27:25altuezisetrecipients: + altuezi, josh.r, davin
2016-12-16 17:27:25altuezisetmessageid: <1481909245.27.0.0644123123684.issue28982@psf.upfronthosting.co.za>
2016-12-16 17:27:25altuezilinkissue28982 messages
2016-12-16 17:27:24altuezicreate