in reply to Re: Fast provider feeding slow consumer
in thread Fast provider feeding slow consumer
Dear BrowserUk , the script is almost done, After applying both changes it begun working, but there is something wrong when the walker receives the line from the listener, it receives only a number instead of the complete line.
I put them to print as following:
and got the following:sub listener { my( $Qout ) = @_; require IO::Socket::INET::Daemon; ## Requiring here means other +threads don't carry the redundant weight my $host = new IO::Socket::INET::Daemon( host => '172.24.3.208', port => 7777, timeout => 20, callback => { data => sub { my ($io, $host) = @_; chomp( my $line = <$io> ); return 0 unless $line; print "here line is : $line"; $Qout->enqueue( $line ); ## send work to listener return !0; } }, ); $host->run; return; } sub walker { my( $Qin, $Qout ) = @_; while( $Qin->dequeue ) { ## receive work from listener print "here \$\_ is : $_"; my( $type, $ip, $mac, $bsid, $datecode ) = split( ',', $_ ); $mac =~ tr[-][]d;
Im reading the Thread::Queue documentacion and the example provided looks very similar like your method ... I will keep investigating it. Thanks
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Fast provider feeding slow consumer
by BrowserUk (Patriarch) on Apr 26, 2016 at 15:20 UTC | |
it receives only a number instead of the complete line. I have really no idea how that could possibly happen; nor do I see anything in the code you posted that would explain it. If you haven't already solved it; please post the full code that demonstrates the problem and I'll try and re-create it here. With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
by leostereo (Beadle) on Apr 27, 2016 at 17:59 UTC | |
Dear BrowserUk Following , the current running code. Please note that . Since there is still some queries that returns empty values, I must check the result before sending to the db queue. When querie returns empty rssi , I put in the queue back and it takes between 3-8 times to get a valid value. I also introduce some delay, in order to avoid a loop in this process. In comment at line 28 , Im asking if are they going to the walker instead ? That's all . Leandro.
| [reply] [d/l] |
by BrowserUk (Patriarch) on Apr 27, 2016 at 18:52 UTC | |
This is the third copy of the same code you've posted. I downloaded the first copy a couple of hours ago; but as I don't have your DB; nor a bunch of willing clients connecting; nor a gaggle of machines who's smnp I can walk; it's going to take me a while to set things up here to see what is going on in your code. Be patient. With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
by BrowserUk (Patriarch) on Apr 28, 2016 at 18:58 UTC | |
Since there is still some queries that returns empty values, Leandro, this appears to be a bug in IO::Socket::INET::Daemon, in as much as, it frequently calls the data callback when there is nothing to available read; and getline returns undef. I do not have the time to debug that module; but the simple workaround to it, is to move one line of code in your callback. change this:
To become this:
I think that should get you further. (And yes, the comment was wrong!). (And BTW: you really should get into the habit of using strict and my. Debugging would have been much simpler had your code been strict compliant.) With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |
by Anonymous Monk on Apr 27, 2016 at 17:53 UTC | |
Following , the current running code. Please note that . Since there is still some queries that returns empty values, I must check the result before sending to the db queue. When querie returns empty rssi , I put in the queue back and it takes between 3-8 times to get a valid value. I also introduce some delay, in order to avoid a loop in this process. In comment at line 28 , Im asking if are they going to the walker instead ? That's all . Leandro.
| [reply] [d/l] |
by Anonymous Monk on Apr 27, 2016 at 16:12 UTC | |
Regards, Leo.
Please note: | [reply] [d/l] |
Re^3: Fast provider feeding slow consumer
by leostereo (Beadle) on Apr 26, 2016 at 15:31 UTC | |
Ok , the script is working , there is one good and one bad news.
The bad news is that there is 1 on 10 aprox snmp queries that returns empty rssi values. | [reply] |