I have another method which processes items in the queue and then sleeps 3 seconds. The problem (I'm assuming) is that sometines the inotifywait method won't release the lock on the queue. Debugging output states "IN inotifywait thread." This occasionally leads to a large backup of items in the queue. Is there anything I can do to make this work better?################################################################# sub inotifywait { ################################################################# my $self = shift; ### Forces a flush after every write to this pipe. $|++; ### Make a list of exclude patterns using contents of skip file. my $exclude = join ' --exclude=', '', @{$self->{patterns}}; ### Put inotifywait command together. my $cmd = '/usr/local/bin/inotifywait -mrqc ' . $exclude . ' --fromfile=' . $self->{bdir} . '/list -e close_write,delete |'; $self->debug(qq{$cmd\n}); $pid = open INOTIFY, $cmd or die $!; while (my $output = <INOTIFY>) { chomp $output; $q->enqueue($output); $self->debug(qq{IN inotifywait thread.\n}); $self->debug("Items in queue: " . scalar $q->pending() . "\n") +; } }
In reply to Thread::Queue locking question by mhearse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |