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

Port accessories to asyncio #76

Open
wants to merge 4 commits into
base: asyncio_run
Choose a base branch
from

Conversation

thomaspurchas
Copy link

This should merge into #74. Gonna start working on moving the HTTP bridge.

Unfortunately there are some limits to running the event loop in threads. Notably subprocess don't work in threads, unless the main thread is running an event loop.

I think I might start work migrating the driver over to asyncio, so an event loop is running in the main thread.

With regards to this port, feedback welcome, also testing as I don't have access to all the hardware.

Not a complete port, unfortunately some of the dependent libraries don’t support asyncio at the moment. However as Accessories are still running in separate threads at the moment we can ignore that.

Additionally subprocess can’t use asyncio until the main thread is converted.
@ikalchev
Copy link
Owner

ikalchev commented Apr 1, 2018

Hey! I will go over the PR later when I get to a computer. As for the loop in the driver - this is the core of the PR I opened, would you mind if I finish it?

@thomaspurchas
Copy link
Author

Ahh, I thought the PR you opened was only for the Accessory.run method. Didn't realise you where gonna redo the accessory driver as well!

This makes sure that each accessory thread get a complete event loop to run the accessory with. Also ensure that the event loop is shutdown cleanly.
@thomaspurchas thomaspurchas changed the title [WIP] Port accessories to asyncio Port accessories to asyncio Apr 1, 2018
@cdce8p cdce8p mentioned this pull request Apr 2, 2018
@ikalchev
Copy link
Owner

Hey! Too busy the last week, but I submitted the asyncio today (in dev). Could you revise this?

@thomaspurchas
Copy link
Author

thomaspurchas commented Apr 13, 2018 via email

base36
aiohttp==3.1.1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that we add a dependency that is only used for an optional accessory. If that's the way to go, we should move all optional accessories elsewhere #43.

@ikalchev
Copy link
Owner

Note that one of the merges broke the accessories (the Category is now in costs.py and is not a class). Will try to fix this soon

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

Successfully merging this pull request may close these issues.

None yet

3 participants