Skip to content

Commit

Permalink
Fix Apache Tailer deprecated methods usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
tinevez committed Nov 7, 2024
1 parent 61d957e commit b8deea7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/main/java/fiji/plugin/trackmate/cellpose/CellposeDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -154,13 +155,13 @@ public boolean process()
* the CPU and if we are on Mac. I tested multiprocessing on CPU under
* windows, and there is no benefit for Windows. But there is a strong
* speedup on Mac.
*
*
* On a PC with Windows, forcing Cellpose to run with the CPU: There is
* no benefit from splitting the load between 1,2, 10 or 20 processes.
* It seems like 1 Cellpose process can already use ALL the cores by
* itself and running several Cellpose processes concurrently does not
* lead to shorter processing time.
*
*
* For a source image 1024x502 over 92 time-points, 3 channels: - 1
* thread -> 24.4 min - 8 thread -> 4.1 min (there is not a x8 speedup
* factor, which is to be expected)
Expand Down Expand Up @@ -195,7 +196,12 @@ public boolean process()
*/

// Redirect log to logger.
final Tailer tailer = Tailer.create( cellposeLogFile, new LoggerTailerListener( logger ), 200, true );
final Tailer tailer = Tailer.builder()
.setFile( cellposeLogFile )
.setTailerListener( new LoggerTailerListener( logger ) )
.setDelayDuration( Duration.ofMillis( 200 ) )
.setTailFromEnd( true )
.get();

final ExecutorService executors = Executors.newFixedThreadPool( nConcurrentTasks );
final List< String > resultDirs = new ArrayList<>( nConcurrentTasks );
Expand All @@ -216,7 +222,7 @@ public boolean process()
}
finally
{
tailer.stop();
tailer.close();
logger.setStatus( "" );
logger.setProgress( 1. );
}
Expand Down Expand Up @@ -346,7 +352,7 @@ public boolean process()
/**
* Add a hook to delete the content of given path when Fiji quits. Taken
* from https://stackoverflow.com/a/20280989/201698
*
*
* @param path
*/
protected static void recursiveDeleteOnShutdownHook( final Path path )
Expand Down

0 comments on commit b8deea7

Please sign in to comment.