daria-malkova commented on a change in pull request #16611:
URL: https://github.com/apache/beam/pull/16611#discussion_r798557460



##########
File path: playground/backend/internal/code_processing/code_processing.go
##########
@@ -406,6 +409,31 @@ func cancelCheck(ctx context.Context, pipelineId 
uuid.UUID, cancelChannel chan b
        }
 }
 
+// readGraphFile reads graph from the file and keeps it to the cache.
+// If context is done it means that the code processing was finished 
(successfully/with error/timeout).
+// Write graph to the cache if this in the file.
+// In other case each pauseDuration checks that graph file exists or not and 
try to save it to the cache.
+func readGraphFile(pipelineLifeCycleCtx, backgroundCtx context.Context, 
cacheService cache.Cache, graphFilePath string, pipelineId uuid.UUID) {
+       ticker := time.NewTicker(pauseDuration)
+       for {
+               select {
+               // waiting when graph file appears
+               case <-ticker.C:
+                       if _, err := os.Stat(graphFilePath); err == nil {
+                               ticker.Stop()
+                               utils.ReadAndSetToCacheGraph(backgroundCtx, 
cacheService, pipelineId, graphFilePath)

Review comment:
       The second option. Since we already check that file exists - then if we 
get an error it will not be related to the existence of the file, but rather 
the other error. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to