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

Completion Block called twice #35

Closed
jeremyquinn opened this issue Dec 18, 2015 · 4 comments
Closed

Completion Block called twice #35

jeremyquinn opened this issue Dec 18, 2015 · 4 comments

Comments

@jeremyquinn
Copy link

I have classes extending Operation, that add a completionBlock to self during init, to run a custom completionBlock.
The completionBlock is running twice.
There was a similar problem with Dan Thorpe's Operations GitHub project, it looks very similar : ProcedureKit/ProcedureKit#123

@mcmurrym
Copy link
Contributor

I think the fix should be not allowing completionBlock property to operate at all within PSOperations. We have seen this issue, we have also seen weird time of the execution of the block which makes the state of the operation in the completionBlock inconsistent (regardless of PSOperations). I believe @davedelong has even filed a radar to have this property deprecated. If you want to execute code at the end of an operation try the Observer class, you can easily do it with BlockObserver and it will always execute at the expected time.

That said, we are always open to pull requests for the fix.

@davedelong
Copy link
Contributor

I'd totally be in favor of seeing this property marked as unavailable. And yes, I did file that bug: rdar://problem/23915499 Deprecate completionBlock

@jeremyquinn
Copy link
Author

Hi Guys
Thanks for this.
Yes, I worked around the problem by performing the custom completion block either in a defer clause in Operation.execute or in the case of a GroupOperation, wrapped in a BlockOperation, with the correct dependencies to run last.
This is such a great framework, thanks for all of your work!!

@mcmurrym
Copy link
Contributor

mcmurrym commented Jul 6, 2016

We have now deprecated the completionBlock property within PSOperations.

@mcmurrym mcmurrym closed this as completed Jul 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants