Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/buildstream/_scheduler/queues/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Queue:
# Resources this queues' jobs want
resources = [] # type: List[int]
log_to_file = True
session_elements = None

def __init__(self, scheduler, *, imperative=False):

Expand Down Expand Up @@ -172,6 +173,15 @@ def register_pending_element(self, element):
# Scheduler / Pipeline facing APIs #
#####################################################

# set_session_elements()
#
# Track elements enqueued
#
# Args:
# session_elements (list): a list to put session elements
def set_session_elements(self, session_elements):
self.session_elements = session_elements

# enqueue()
#
# Enqueues some elements
Expand Down Expand Up @@ -381,6 +391,9 @@ def _element_log_path(self, element):
# element (Element): The Element to enqueue
#
def _enqueue_element(self, element):
if self.session_elements is not None:
self.session_elements.append(element)

status = self.status(element)

if status == QueueStatus.SKIP:
Expand Down
3 changes: 1 addition & 2 deletions src/buildstream/_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,7 @@ def _add_queue(self, queue, *, track=False):
if not track and not self.queues:
# First non-track queue
queue.set_required_element_check()

queue.set_session_elements(self.session_elements)
self.queues.append(queue)

# _enqueue_plan()
Expand All @@ -1828,7 +1828,6 @@ def _add_queue(self, queue, *, track=False):
def _enqueue_plan(self, plan, *, queue=None):
queue = queue or self.queues[0]
queue.enqueue(plan)
self.session_elements += plan
Copy link
Contributor

Choose a reason for hiding this comment

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

The frontend still uses Stream.session_elements, which is now always empty.

I don't see how this branch can work as it is, but I could be missing something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We pass the list to the queue a bit earlier

            queue.set_session_elements(self.session_elements)

which then fills it as elements are getting enqueued.

Yeah, it's a bit confusing but I couldn't find a better way to do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess the alternative is to make Element support more than one callback when it becomes required? This way both the Stream and the Queue can pass their own callbacks?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, it's just a reference to the list created in Stream. I think set_session_elements() threw me off as that doesn't actually set any elements, it just passes a reference to the list. With clearer naming and/or comment, it might be ok.


# _run()
#
Expand Down
Loading