Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue21723

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:Float maxsize is treated as infinity in asyncio.Queue
Type:behaviorStage:
Components:asyncioVersions:Python 3.5
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: emptysquare, gvanrossum, python-dev, vajrasky, vstinner, yselivanov
Priority:normalKeywords:patch

Created on2014-06-11 15:59 byvajrasky, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
asyncio_queue_accept_handles_maxsize.patchvajrasky,2014-06-11 15:59review
Messages (8)
msg220280 -(view)Author: Vajrasky Kok (vajrasky)*Date: 2014-06-11 15:59
import asyncioloop = asyncio.get_event_loop()q = asyncio.Queue(maxsize=1.2, loop=loop)q.put_nowait(1)q.put_nowait(1)q.put_nowait(1)q.put_nowait(1)q.put_nowait(1).... and so onIt seems counter intuitive for my innocent eyes. As comparison with the traditional queue:import queueq = queue.Queue(maxsize=1.2)q.put(1)q.put(1)q.put(1) -> blockingHere is the patch to make the behaviour consistent with its sibling.
msg220283 -(view)Author: STINNER Victor (vstinner)*(Python committer)Date: 2014-06-11 16:12
It looks strange to use a float as maxsize. I suggest to raise a TypeError in the constructor if the type is not int, or maybe to cast maxsize parameter to an int.
msg220289 -(view)Author: Yury Selivanov (yselivanov)*(Python committer)Date: 2014-06-11 17:22
FWIW, this can also be resolved by fixing Queue.full to do "self.qsize() >= self._maxsize" instead of "self.qsize() == self._maxsize".I generally don't like implicit casts as they break duck typing.
msg220360 -(view)Author: Vajrasky Kok (vajrasky)*Date: 2014-06-12 16:08
"It looks strange to use a float as maxsize." => It is. But the float could be coming programmatically. Float value interpreted as infinity could give a shock for some people."maybe to cast maxsize parameter to an int." => ceiling or flooring?
msg220840 -(view)Author: Guido van Rossum (gvanrossum)*(Python committer)Date: 2014-06-17 15:51
The patch looks fine to me.
msg220899 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2014-06-17 21:40
New changesetccfc13183fea by Victor Stinner in branch '3.4':Issue#21723: asyncio.Queue: support any type of number (ex: float) for thehttp://hg.python.org/cpython/rev/ccfc13183feaNew changeseta2f115bfa513 by Victor Stinner in branch 'default':(Merge 3.4) Issue#21723: asyncio.Queue: support any type of number (ex: float)http://hg.python.org/cpython/rev/a2f115bfa513
msg220906 -(view)Author: STINNER Victor (vstinner)*(Python committer)Date: 2014-06-17 22:07
Thanks Vajrasky, I aplied your patch.
msg220907 -(view)Author: STINNER Victor (vstinner)*(Python committer)Date: 2014-06-17 22:07
Change also pushed to Tulip (changeset3a392e5328c0).
History
DateUserActionArgs
2022-04-11 14:58:04adminsetgithub: 65922
2014-06-17 22:44:52emptysquaresetnosy: +emptysquare
2014-06-17 22:07:47vstinnersetmessages: +msg220907
2014-06-17 22:07:42vstinnersetstatus: open -> closed
resolution: fixed
messages: +msg220906
2014-06-17 21:40:59python-devsetnosy: +python-dev
messages: +msg220899
2014-06-17 15:51:29gvanrossumsetmessages: +msg220840
2014-06-12 16:08:07vajraskysetmessages: +msg220360
2014-06-11 17:22:16yselivanovsetmessages: +msg220289
2014-06-11 16:12:32vstinnersetmessages: +msg220283
2014-06-11 15:59:54vajraskycreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp