-
Notifications
You must be signed in to change notification settings - Fork 64
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
fix sending from forked container #1692
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1692 +/- ##
==========================================
- Coverage 80.98% 74.92% -6.07%
==========================================
Files 304 304
Lines 15480 15180 -300
==========================================
- Hits 12536 11373 -1163
- Misses 2944 3807 +863
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
❓ E2E |
) | ||
self._op_processor.set_post_trigger_side_effect(self._op_processor.start) |
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.
Isn't it simpler to set it as a part of the constructor?
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.
its actually a bit tricky to do it in a constructor. This PR actually moves post_trigger_side_effect
assigment from constructor to setter function. Previously we had
# self._op_processor was already defined
self._op_processor = LazyOperationProcessorWrapper(
operation_processor_getter=partial(
get_operation_processor,
mode=self._mode,
container_id=self._id,
container_type=self.container_type,
backend=self._backend,
lock=self._lock,
flush_period=self._flush_period,
queue=self._signals_queue,
),
post_trigger_side_effect=self._op_processor.start,
)
so in line post_trigger_side_effect=self._op_processor.start
self._op_processor
was pointing to already defined op_processor
(ex. AsyncOperationProcessor
).
It was also used by parent process (fork model) and therefore both processes would reference the same consumer
thread which caused errors down the line. (ex. one process when finishing was forced to join on already finished thread)
Now in fork childself._op_processor
points to LazyOperationProcessorWrapper
and when triggered will create new AsyncOperationProcessor
instance with new consumer
thread.
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.
You don't have to provide it as a parameter. You can set up it internally in the LazyOperationProcessor
as:
self._post_trigger_side_effect=self.start
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.
I know that you cannot provide it as a parameter because you don't have an instance created 😉
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.
but self
in this scope points to MetadataContainer
not LazyOperationProcessorWrapper
.
If it wasn't the case this code would work as expected previously
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 theory I could define post_trigger_side_effect
as function that takes one argument - self
of LazyOperationProcessorWrapper
and work my way around that but I think current impl is cleaner
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.
I mean that you can set this property internally as a part of a constructor of LazyOperationProcessorWrapper
like: self._post_trigger_side_effect=self.start
. Think that it needs to be always called and it's an "atomic" operation that you have to initialize OperationProcessor and once it's created, run start
on init. I've prepared some suggestions here: #1705
Before submitting checklist
Did you ask the docs owner to review all the user-facing changes?