Skip to content

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

Closed

Description

@tvoinarovskyi
  • 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?

Activity

  1. 1st1 commented on Nov 10, 2017

    @1st1
    Member

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

  2. 1st1 commented on Nov 13, 2017

    @1st1
    Member

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

  3. 1st1 commented on Nov 27, 2017

    @1st1
    Member

    Please try uvloop v0.9.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions