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

awaiting a future attached to a different loop #43

Open
jensbjorgensen opened this issue Oct 13, 2022 · 7 comments
Open

awaiting a future attached to a different loop #43

jensbjorgensen opened this issue Oct 13, 2022 · 7 comments

Comments

@jensbjorgensen
Copy link

Running on a recent raspberry pi, I tried to run the script under the tutorial heading

Talking to Python from the Browser

Once I open the link in the browser the script begins rapidly spewing errors of the form:

RuntimeError: Task <Task pending name='Task-11627' coro=<Queue.get() running at /usr/lib/python3.9/asyncio/queues.py:166> cb=[<TaskWakeupMethWrapper object at 0xa8a25a18>()]> got Future attached to a different loop
Got unrecognized error from task. ignoring:
Traceback (most recent call last):
File "/home/pi/src/rtcbot/rtcbot/base/base.py", line 365, in _get
await self._getTask
File "/usr/lib/python3.9/asyncio/queues.py", line 166, in get
await getter

As the src path suggests, I've pulled latest git in case this was somehow recently fixed.

Looking at the code in base.py around 365, self._getTask created just above it, should yield the same loop where await is called on 365 so I'm a bit confused about the error. But that's the error .... not sure what to make of it.

@jensbjorgensen
Copy link
Author

Actually having just typed it, actually I think it does make sense. The Queue is created in a different loop than where it was awaited. I'm not familiar with the code yet but I'll dig around.

@dkumor
Copy link
Owner

dkumor commented Oct 13, 2022

This is surprising - as I understand it, you are using the tutorial code without modification? I will need to check if anything changed in Python 3.9 that might have caused the issue.

@jensbjorgensen
Copy link
Author

jensbjorgensen commented Oct 13, 2022

yes, I copied pasted the code there verbatim. I'm running Raspbian 11, the python I'm using is the stock distro version

Python 3.9.2 (default, Mar 12 2021, 04:06:34)
[GCC 10.2.1 20210110] on linux

as I say, nothing fancy was needed to trigger it, just ran the script as it is in the tutorial, and opened the URL (from my laptop, not directly on the Pi)

@dkumor
Copy link
Owner

dkumor commented Oct 15, 2022

I have confirmed the issue on pi 4 with latest raspbian. I don't know if I will have time to look into it this weekend, so it might be a week or two before I can fix it.

@dkumor
Copy link
Owner

dkumor commented Oct 23, 2022

It looks like get_event_loop is being deprecated, which is used extensively by RTCBot to get the loop. I have fixed the issue on my end by adding the following code to the top of the file:

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

and then setting the loop manually:

conn = RTCConnection(loop=loop)
web.run_app(app,loop=loop)

I will try to fix this more deeply.

@beniroquai
Copy link

Hey @dkumor thanks for your effort to keep this project alive! I'm returning back to webrtc ;-)
Did you have a chance to look into this already? I can confirm this issue on python3.9 on my mac, too.

@beniroquai
Copy link

beniroquai commented Dec 20, 2022

Quick update: I tested the code on python3.8 and it shows the same behaviour. Perhaps a downgrade or aiohttp may help?

But indeed, your workaround seems to do the job! :-)

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

No branches or pull requests

3 participants