in reply to Re^4: Performance and CPU load: sysread, IO::Select and/or Storable::thaw
in thread Performance and CPU load: sysread, IO::Select and/or Storable::thaw
I looked a bit closer at your code and noticed that you add STDIN to your select call instead of readHandle. Any reason? It might be that this is your problem.
I tried the following test script and it works. I get output every 5 seconds:
#!/usr/bin/perl use warnings; use Data::Dumper; use IO::Handle; use IPC::Open2; use IO::Select; my $i; my ($readHandle, $writeHandle) = (IO::Handle->new, IO::Handle->new); my $pid = open2($readHandle, $writeHandle, 'bc'); $writeHandle->autoflush(1); $readHandle->autoflush(1); my $select = IO::Select->new(); $select->add($readHandle); while (1) { print $i++,"\n"; my ($handle) = $select->can_read(5); }
Interestingly it works even when I turn off blocking, which means my previous notion that can_read would not wait if blocking is turned off might be false.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Performance and CPU load: sysread, IO::Select and/or Storable::thaw
by DBX (Pilgrim) on Jun 30, 2010 at 13:49 UTC |