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

Multiplexing command batches and control signals #408

Merged
merged 4 commits into from
May 28, 2021

Conversation

azawlocki
Copy link
Contributor

@azawlocki azawlocki commented May 28, 2021

This PR implements processing of a stream of command batches generated by a service state handler, interleaved with a stream control signals.

Resolves #396

@azawlocki azawlocki requested a review from a team May 28, 2021 08:02
@azawlocki azawlocki changed the base branch from master to blue/services-api May 28, 2021 08:03
Base automatically changed from blue/services-api to master May 28, 2021 08:27
# Repeatedly wait on one of `(batch_task, signal_task)` to finish.
# If it's the first one, retrieve a batch from its result and handle it.
# If it's the second -- retrieve and handle a signal.
# Any finished task is replaced with a new one, so there are always two.
Copy link
Contributor

Choose a reason for hiding this comment

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

LOL :D

always two

if batch_task is None:
batch_task = loop.create_task(handler.__anext__())
if signal_task is None:
signal_task = loop.create_task(instance.control_queue.get())
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should remove ServiceInstance.get_control_signal then ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed in 648c114

Comment on lines 356 to 362
if batch_task:
batch_task.cancel()
await batch_task
if signal_task:
signal_task.cancel()
await signal_task

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should go before the above logger message, and maybe a new .debug one should be added above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, 648c114

Copy link
Contributor

@shadeofblue shadeofblue left a comment

Choose a reason for hiding this comment

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

minor comments above ^

@@ -299,7 +290,7 @@ async def _run_instance(self, ctx: WorkContext):
instance = ServiceInstance(service=self._service_class(self, ctx))
self.__instances.append(instance)

logger.info(f"{instance.service} commissioned")
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@shadeofblue shadeofblue left a comment

Choose a reason for hiding this comment

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

all-ok-here-22822524

@azawlocki azawlocki merged commit 112c3ba into master May 28, 2021
@shadeofblue shadeofblue deleted the az/batch+signal-multiplexer branch May 28, 2021 14:34
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.

address the issue of handler blocking in the Services API
2 participants