NetworkingInOperations-Example
NetworkingInOperations-Example copied to clipboard
Operation queue deadlock condition
trafficstars
The operation queue will deadlock if cancelAllOperations is called on the queue before all operations have executed. The culprit is in the start method
guard !isCancelled else { finish() return }
The state value will be .ready which will cause the finish method to never change the state to .finished. Thus, causing a deadlock.
You can either update the guard statement to manually set the state to .finish. Or, change the finish method to not check for the isExecuting state.
@sgraesser17 thanks for pointing it out, I'll have a think about it and update the project to avoid this