★ wanayoo — archive 1999 https://github.com/MagicStack/uvloop/issues/102Nouvelle recherche | Portail wanayoo
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

Should `float("inf")` for timeout raise an Overflow error? #102

Closed
tvoinarovskyi opened this issue Aug 27, 2017 · 3 comments
Closed

Should `float("inf")` for timeout raise an Overflow error? #102

tvoinarovskyi opened this issue Aug 27, 2017 · 3 comments

Comments

@tvoinarovskyi
Copy link

@tvoinarovskyi tvoinarovskyi commented Aug 27, 2017

  • uvloop version: 0.8.0
  • Python version: python 3.5.0
  • Platform: osx
  • Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: yes

Rather this is to confirm if this is actually a bug )

Code:

import asyncio
import uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())


async def test():
    await asyncio.wait_for(asyncio.sleep(10), timeout=float("inf"))

loop = asyncio.get_event_loop()
loop.run_until_complete(test())

Error:

Traceback (most recent call last):
  File "kafka-python/kafka/record/test.py", line 10, in <module>
    loop.run_until_complete(test())
  File "uvloop/loop.pyx", line 1203, in uvloop.loop.Loop.run_until_complete (uvloop/loop.c:25632)
  File "uvloop/future.pyx", line 146, in uvloop.loop.BaseFuture.result (uvloop/loop.c:109361)
  File "uvloop/future.pyx", line 101, in uvloop.loop.BaseFuture._result_impl (uvloop/loop.c:108900)
  File "uvloop/future.pyx", line 372, in uvloop.loop.BaseTask._fast_step (uvloop/loop.c:112669)
  File "kafka-python/kafka/record/test.py", line 7, in test
    await asyncio.wait_for(asyncio.sleep(10), timeout=float("inf"))
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/tasks.py", line 362, in wait_for
    timeout_handle = loop.call_later(timeout, _release_waiter, waiter)
  File "uvloop/loop.pyx", line 1048, in uvloop.loop.Loop.call_later (uvloop/loop.c:23438)
OverflowError: cannot convert float infinity to integer

The problem comes from aio-libs/aiokafka#210, basically, I put in float('inf') for the timeout in wait(fs) call and it worked with vanilla asyncio, but crashed on uvloop. Docs for asyncio don't really specify that timeout needs to be in a specific range. Semantically specifying float('inf') should probably be the same as None (no timeout).

The reasoning for using float('inf') is simple, we can do computations with it and still get a proper float type.
What do you think?

@1st1
Copy link
Member

@1st1 1st1 commented Nov 10, 2017

libuv won't work with inf. I guess a reasonable option would be to convert inf timeouts to 100 years from now.

1st1 added a commit that referenced this issue Nov 11, 2017
@1st1
Copy link
Member

@1st1 1st1 commented Nov 13, 2017

Fixed in master. Will be in the next uvloop release (0.9.0) soon.

@1st1 1st1 closed this Nov 13, 2017
@1st1
Copy link
Member

@1st1 1st1 commented Nov 27, 2017

Please try uvloop v0.9.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.