diff --git a/bean-query-daemon-lib.pl b/bean-query-daemon-lib.pl index ad4eb1b..089f163 100644 --- a/bean-query-daemon-lib.pl +++ b/bean-query-daemon-lib.pl @@ -29,7 +29,16 @@ sub BeancountQuerySubmit($;$) { $BEANCOUNT_QUERY{question} = $question; $BEANCOUNT_QUERY{format} = $format if defined $format; (tied %BEANCOUNT_QUERY)->shunlock; - while (not defined $BEANCOUNT_QUERY{fifoName}) { sleep 1; } + my $cnt = 0; + while (not defined $BEANCOUNT_QUERY{fifoName}) { + sleep 1; + if ($cnt++ >= (5 * 60)) { + (tied %BEANCOUNT_QUERY)->shlock; + $BEANCOUNT_QUERY{question} = $BEANCOUNT_QUERY{format} = undef; + (tied %BEANCOUNT_QUERY)->shunlock; + die "Unable to initiate query to beancount server\n"; + } + } unless (-p $BEANCOUNT_QUERY{fifoName}) { (tied %BEANCOUNT_QUERY)->shlock; $BEANCOUNT_QUERY{question} = $BEANCOUNT_QUERY{format} = undef;