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

Can't use asyncio event loop in widgets #1046

Closed
infmagic2047 opened this issue Apr 22, 2017 · 5 comments · Fixed by #1644
Closed

Can't use asyncio event loop in widgets #1046

infmagic2047 opened this issue Apr 22, 2017 · 5 comments · Fixed by #1644

Comments

@infmagic2047
Copy link
Contributor

I am creating a widget that uses asyncio to run some external command (with asyncio.create_subprocess_exec). It doesn't work, and raises the RuntimeError("Cannot add child handler, the child watcher does not have a loop attached") exception instead.

If my understanding of the code is correct, calling set_event_loop after new_event_loop should fix this issue, but I'm not sure whether it will cause other problems.

@frostidaho
Copy link
Contributor

Do you need stdout or stderr from the program? If not you could just use qtile.cmd_spawn().
You can also get at the underlying eventloop with qtile._eventloop, so you can call qtile._eventloop.subprocess_exec

@infmagic2047
Copy link
Contributor Author

I need the stdout in this case, so I can't use cmd_spawn().

Using qtile._eventloop explicitly won't help here. subprocess_exec() uses asyncio.get_child_watcher() internally, which uses the event loop set with set_event_loop().

@mgeier
Copy link

mgeier commented Apr 6, 2018

I just stumbled upon this because I was getting the same error (but completely unrelated to qtile, I don't even know what that is).
I still have no clue about anything related with asyncio, but in my case something like this helped (called from the main thread):

asyncio.get_child_watcher().attach_loop(my_loop)

@github-actions
Copy link

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days.

tych0 added a commit to tych0/qtile that referenced this issue Apr 19, 2020
This will enable widgets to do things using our event loop if they want.

Closes qtile#1046

Signed-off-by: Tycho Andersen <[email protected]>
ramnes pushed a commit that referenced this issue Apr 19, 2020
This will enable widgets to do things using our event loop if they want.

Closes #1046

Signed-off-by: Tycho Andersen <[email protected]>
@ramnes
Copy link
Member

ramnes commented Apr 19, 2020

Just got fixed by @tych0 , sorry it took so long!

zordsdavini pushed a commit to zordsdavini/qtile that referenced this issue Apr 23, 2020
This will enable widgets to do things using our event loop if they want.

Closes qtile#1046

Signed-off-by: Tycho Andersen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants