Skip to content

uasyncio call_soon() and call_later() fail when arguments are passed #179

@peterhinch

Description

@peterhinch

These methods pack multiple args into a tuple, unpacking them before passing them to call_at_(). The latter expects a tuple and hence throws an exception:

import uasyncio as asyncio

def cb(x, y):
    print('x = {} y = {}'.format(x, y))

async def foo():
    loop.call_soon(cb, 5, 6)
    await asyncio.sleep(1)

loop = asyncio.get_event_loop()
loop.run_until_complete(foo())
Traceback (most recent call last):
  File "<stdin>", line 11, in <module>
  File "uasyncio/core.py", line 129, in run_until_complete
  File "uasyncio/core.py", line 121, in run_forever
  File "uasyncio/core.py", line 85, in run_forever
  File "uasyncio/core.py", line 126, in _run_and_stop
  File "<stdin>", line 7, in foo
  File "uasyncio/core.py", line 32, in call_soon
TypeError: function takes 4 positional arguments but 5 were given
>>>  

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions