-
Notifications
You must be signed in to change notification settings - Fork 110
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
Conversation
23f0fdb
to
78b12d3
Compare
This needs rebasing first |
Can this solve Lines 28 to 29 in 881a350
|
e3682ca
to
a80bea8
Compare
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) |
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.
Looks good! But (just our of curiosity mostly), why not to to use:
self._tasks[iens].add_done_callback(self._on_job_complete)
?
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 it's not when the task is done running, it's when the job is COMPLETED
successfully.
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.
Yes, but we can check in _on_job_complete
that self.state == COMPLETED
?
a955563
to
f7f4a56
Compare
src/ert/scheduler/event_sender.py
Outdated
): | ||
while True: | ||
event = await self.events.get() | ||
print(f"==SENDING {event=}") |
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.
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: |
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.
is this driver arg related to the commit message, or is it some other refactoring?
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.
It's part of the commit. The Job
object obtains a Driver
only when it is supposed to use it, not before.
42e8ebb
to
f34acb9
Compare
`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`.
Closing as this doesn't really solve anything. There will be a cyclic dependency regardless. |
Scheduler
has a reference toJob
andJob
has a reference toScheduler
. AddingEventSender
lets us resolve this cycle as nowScheduler
has a reference toJob
s andEventSender
, but eachJob
only refers toEventSender
.