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
Dynamic batch #14
Dynamic batch #14
Conversation
9558968
to
15990ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need:
- Readme
- bump version
aqueduct/worker.py
Outdated
"""Provides suitable for processing tasks.""" | ||
while True: | ||
try: | ||
def _get_task(self, timeout: float): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def _get_task(self, timeout: float): | |
def _get_task(self, timeout: float) -> Optional[BaseTask]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
aqueduct/worker.py
Outdated
if self._stop_task or timeout <= 0: | ||
return batch | ||
|
||
timeout = max(timeout, 0.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
timeout = max(timeout, 0.1) | |
timeout = max(timeout, 0.001) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
aqueduct/worker.py
Outdated
|
||
# wait first task | ||
while True: | ||
task = self._get_task(10.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment why do we use exactly 10 seconds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added comment
15990ae
to
3b4fee6
Compare
aqueduct/flow.py
Outdated
@@ -243,18 +244,34 @@ def step_names(handlers): | |||
return {queue_: f'from_{from_}_to_{to}' | |||
for queue_, (from_, to) in zip(self._queues, step_names(self._contexts))} | |||
|
|||
async def _fetch_processed(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In line 52 you need to change default timeout to None: batch_timeout: Optional[int] = None
try: | ||
def _get_task(self, timeout: float): | ||
try: | ||
if timeout == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because 0
change behavior of batching, it is better to use None-value. To show users that behavior is different than integer value.
When batch_timeout is set to 0 use alternative batching stratagy.
Instead of waiting fixed timeout while batch is ready, grab all task6 that are curentely in input queue and process them right away. We effectively using queue as batch buffer.