google-research / CVD-paper-mobile-camera-example

Apache License 2.0
6 stars 4 forks source link

Optimizing synchronization: release lock in finally block, synchronize block in the same coroutine #59

Closed MJ1998 closed 6 months ago

MJ1998 commented 6 months ago

Fixes #58 and #55

Changes Made:

  1. Removal of the separate coroutine launch for synchronization, leveraging the finite emit cold flow from synchronize().
  2. Introducing a try-catch-finally block around synchronize() to handle exceptions.
  3. Increasing the connection timeout to 30 seconds to address ConnectTimeoutException occurrences.

Positive side effect: elimination of the need for an additional coroutine for collecting SyncUploadStates.

Testing: Network connection was deliberately shut off to observe the behavior during ConnectTimeoutException. The lock is successfully released, and the worker returns Result.retry. Successfully observe last set progress from both periodic and one time sync workers.