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

Add EventSender to resolve dependency cycle #6864

Closed
wants to merge 1 commit into from

Conversation

pinkwah
Copy link
Contributor

@pinkwah pinkwah commented Dec 29, 2023

Scheduler has a reference to Job and Job has a reference to Scheduler. Adding EventSender lets us resolve this cycle as now Scheduler has a reference to Jobs and EventSender, but each Job only refers to EventSender.

@pinkwah pinkwah force-pushed the cyclic branch 2 times, most recently from 23f0fdb to 78b12d3 Compare December 29, 2023 12:30
@pinkwah pinkwah self-assigned this Dec 29, 2023
@xjules
Copy link
Contributor

xjules commented Jan 3, 2024

This needs rebasing first

@berland
Copy link
Contributor

berland commented Jan 10, 2024

Can this solve

# Duplicated to avoid circular imports
EVTYPE_REALIZATION_TIMEOUT = "com.equinor.ert.realization.timeout"
?

@pinkwah pinkwah force-pushed the cyclic branch 3 times, most recently from e3682ca to a80bea8 Compare January 11, 2024 11:23
self._jobs: MutableMapping[int, Job] = {
real.iens: Job(self, real) for real in (realizations or [])
self._jobs: Mapping[int, Job] = {
real.iens: Job(real, on_complete=self._on_job_complete)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good! But (just our of curiosity mostly), why not to to use:
self._tasks[iens].add_done_callback(self._on_job_complete)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it's not when the task is done running, it's when the job is COMPLETED successfully.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but we can check in _on_job_complete that self.state == COMPLETED?

@pinkwah pinkwah force-pushed the cyclic branch 5 times, most recently from a955563 to f7f4a56 Compare January 17, 2024 12:22
):
while True:
event = await self.events.get()
print(f"==SENDING {event=}")
Copy link
Contributor

@berland berland Jan 23, 2024

Choose a reason for hiding this comment

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

leftover print statement?

async def _submit_and_run_once(self, sem: asyncio.BoundedSemaphore) -> None:
async def _submit_and_run_once(
self, sem: asyncio.BoundedSemaphore, driver: Driver
) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

is this driver arg related to the commit message, or is it some other refactoring?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's part of the commit. The Job object obtains a Driver only when it is supposed to use it, not before.

@pinkwah pinkwah force-pushed the cyclic branch 4 times, most recently from 42e8ebb to f34acb9 Compare February 16, 2024 12:59
`Scheduler` has a reference to `Job` and `Job` has a reference to
`Scheduler`. Adding `EventSender` lets us resolve this cycle as now
`Scheduler` has a reference to `Job`s and `EventSender`, but each `Job`
only refers to `EventSender`.
@pinkwah
Copy link
Contributor Author

pinkwah commented Feb 26, 2024

Closing as this doesn't really solve anything. There will be a cyclic dependency regardless.

@pinkwah pinkwah closed this Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants