4343use Proc::PID::File;
4444use Data::Dumper;
4545
46+ my $CAN_USE_THREADS = 0;
47+ $CAN_USE_THREADS = eval ' use threads; 1' ;
48+
4649use PCAP;
4750use PCAP::Cli;
4851
@@ -99,7 +102,7 @@ sub load_config {
99102 }
100103 if (exists $options -> {' COMPOSITE_FILTERS' }-> {' not_sanger_workflow' }) {
101104 my %bl_workflows = map { $_ => 1 } split /[\n,]/, $options -> {' COMPOSITE_FILTERS' }-> {' not_sanger_workflow' };
102- $options -> {' COMPOSITE_FILTERS' }-> {' not_sanger_workflow' } = [keys \ %bl_workflows ];
105+ $options -> {' COMPOSITE_FILTERS' }-> {' not_sanger_workflow' } = [keys %bl_workflows ];
103106 }
104107
105108 croak sprintf q{ 'KEY_FILE' Ssection is absent from %s} , $options -> {' config' } unless ($cfg -> SectionExists(' KEY_FILES' ));
@@ -132,8 +135,6 @@ sub load_config {
132135 return 1;
133136}
134137
135- use threads;
136-
137138sub pull_data {
138139 my ($options , $to_process ) = @_ ;
139140
@@ -153,6 +154,10 @@ sub pull_data {
153154 }
154155
155156 my $thread_count = $options -> {' threads' };
157+ if ($CAN_USE_THREADS == 0) {
158+ warn " Threading is not available perl component will run as a single process" ;
159+ $thread_count = 1;
160+ }
156161
157162
158163 while (@{$to_process } > 0) {
@@ -170,13 +175,13 @@ sub pull_data {
170175
171176 warn " Submitting: $donor ->{donor_unique_id}\n " ;
172177 if ($thread_count > 1) {
173- if (threads-> list(threads::all) < $thread_count ) {
178+ if (threads-> list(threads::all() ) < $thread_count ) {
174179 threads-> create($code_ref , $options , $donor , $orig_base , $donor_base );
175180 # don't sleep if not full yet
176- next if (threads-> list(threads::all) < $thread_count );
181+ next if (threads-> list(threads::all() ) < $thread_count );
177182 }
178- sleep 1 while (threads-> list(threads::joinable) == 0);
179- for my $thr (threads-> list(threads::joinable)) {
183+ sleep 1 while (threads-> list(threads::joinable() ) == 0);
184+ for my $thr (threads-> list(threads::joinable() )) {
180185 $thr -> join ;
181186 if (my $err = $thr -> error) { die " Thread error: $err \n " ; }
182187 }
@@ -187,8 +192,8 @@ sub pull_data {
187192 }
188193 if ($thread_count > 1) {
189194 # last gasp for any remaining threads
190- sleep 1 while (threads-> list(threads::running) > 0);
191- for my $thr (threads-> list(threads::joinable)) {
195+ sleep 1 while (threads-> list(threads::running() ) > 0);
196+ for my $thr (threads-> list(threads::joinable() )) {
192197 $thr -> join ;
193198 if (my $err = $thr -> error) { die " Thread error: $err \n " ; }
194199 }
0 commit comments