thiagokokada / i3pyblocks

A replacement for i3status, written in Python using asyncio.
MIT License
19 stars 2 forks source link

Add PollingExecutorBlock #118

Closed thiagokokada closed 3 years ago

thiagokokada commented 3 years ago

This is a combination of PollingBlock and ExecutorBlock (not necessary it will use multiple inheritance, while Python supports this it can be messy), allowing completely synchronous libraries to be integrated with i3pyblocks using a polling strategy.

We can convert i3pyblocks.blocks.x11.CaffeineBlock as an example of this block.

thiagokokada commented 3 years ago

Another thing: nowadays ExecutorBlock's click_handler() and signal_handler() methods are async. We could implement a click_handler_sync() and signal_handler_sync() that can be used as synchronous alternatives, and call them in click_handler() and signal_handler() with run_async.

So we don't need to care about the difference between sync/async when using ExecutorBlock, at all. In case the async version is needed, we can always override {click,signal}-handler() methods.

Of course, PollingExecutorBlock would have the same methods too.

thiagokokada commented 3 years ago

Closed by #120.