Skip to content

Instantly share code, notes, and snippets.

@daboross
Last active August 29, 2015 14:01
Show Gist options
  • Save daboross/95cca91e5a9ac2f97797 to your computer and use it in GitHub Desktop.
Save daboross/95cca91e5a9ac2f97797 to your computer and use it in GitHub Desktop.
TypeError: send() takes 2 positional arguments but 3 were given

I've created test.py as a self contained example demonstrating the problem I am facing.

In the application I am working on, I have an asyncio.Queue object, in which I put tuples of (asyncio.Future, dict).

However, whenever executing this code using PYTHONASYNCIODEBUG=1, I get a strange error on the queue.get() method.

Here's the error on the test.py script:

$ PYTHONASYNCIODEBUG=1 ./test.py 
Traceback (most recent call last):
  File "./test.py", line 10, in get
    yield from queue.get()
TypeError: send() takes 2 positional arguments but 3 were given
#!/usr/bin/env python3.4
import asyncio
import traceback
@asyncio.coroutine
def get(queue):
try:
# Get the message from the queue
yield from queue.get()
except Exception:
# This is just to show the exception stacktrace
traceback.print_exc()
@asyncio.coroutine
def main_loop():
queue = asyncio.Queue()
asyncio.async(get(queue))
# Add a pair of placeholder values.
asyncio.async(queue.put((asyncio.Future(), None)))
# We need to let this function sleep, so the event loop can process the get() method
yield from asyncio.sleep(0.5)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main_loop())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment