Click here to get back home

Problem with Storable on Windows

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Problem with Storable on Windows Matthew Keene 07-04-2005
Posted by Matthew Keene on July 4, 2005, 9:20 pm
Please log in for more thread options


I'm trying to use Storable in conjunction with IPC::Open3 in order to
send complex data structures between the parent and child processes.
Unfortunately, although this seems to work a treat under Linux (Fedora
Core 4), it doesn't seem to work on Windows, returning the following
message:

Magic number checking on storable file failed at blib\lib\Storable.pm
(autosplit into blib\lib\auto\Storable\fd_retrieve.al) line 323, at
D:\Data\Perl\DBAsyncWorker.pl line 13

Here's my code:

Caller:

#!/usr/bin/perl

use Storable qw(nstore_fd freeze) ;
use IPC::Open3 ;
use IO::Handle ;

autoflush STDOUT ;
print "Caller starting\n" ;
$Storable::Deparse = 1 ;
%parms = ( data_source => 'DBI:Pg:dbname=matthew',
userid => 'matthew',
password => 'vishnu',
statement => 'select * from test_table') ;
$command = 'DBAsyncWorker.pl' ;
print "About to call worker\n" ;
$pid = open3($wtr,$rdr,$err,$command) ;
# This line added for Windows
binmode $wtr ;
print "Worker started\n" ;

while(($line = <$rdr>) !~ 'End') {
if ($line =~ /START/) {
print "Received start command\n" ;
nstore_fd \%parms, $wtr ;
}
else {
print $line ;
}
}


Worker:

#!/usr/bin/perl

use DBI ;
use Data::Dumper ;
use IO::Handle ;
use Storable qw(fd_retrieve thaw) ;

$Storable::Eval = 1 ;

autoflush STDOUT ;
# This line added for Windows
binmode STDIN ;
print "START\n";
$parm_ref = fd_retrieve(\*STDIN) ;
print "Retrieved parm reference\n",Dumper($parm_ref) ;
print "Userid = ",$parm_ref->,"\n" ;
print "Password = ",$parm_ref->,"\n" ;
print "Statement = ",$parm_ref->,"\n" ;
print "End\n" ;

Here's what I've tried, without luck:

* Using store_fd instead of nstore_fd
* Using freeze in the caller, printing the frozen value to $wtr, and
then reading it on the worker using sysread and using thaw

Freeze'ing and thaw'ing within a single program works fine, it's just
when I send it over a file handle that the problem occurs.

Does anybody have any ideas ?




Posted by Thomas Kratz on July 5, 2005, 10:56 am
Please log in for more thread options


Matthew Keene wrote:
> I'm trying to use Storable in conjunction with IPC::Open3 in order to
> send complex data structures between the parent and child processes.
> Unfortunately, although this seems to work a treat under Linux (Fedora
> Core 4), it doesn't seem to work on Windows, returning the following
> message:
>
> Magic number checking on storable file failed at blib\lib\Storable.pm
> (autosplit into blib\lib\auto\Storable\fd_retrieve.al) line 323, at
> D:\Data\Perl\DBAsyncWorker.pl line 13

[code snipped]

You don't have a problem with Storable, but with IPC::Open3. I modified
your code a bit and found that the data the caller sent never made it to
the client. So you try to thaw an empty string, which Storable complains
about. Reading from the pipe in the worker never succeeds. I'm not an
expert, but googling for problems with IPC::Open3 on Windows will show a
few threads. If you don't find a solution there, I would suggest doing the
communication over sockets. At least that works (it does for me).
This could perhaps all be related to select working only on sockets under
Windows.

Thomas

--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*3),,mg,@_=mapsplit;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-


Similar ThreadsPosted
Storable - Perl Mod September 20, 2004, 6:11 am
cgi.pm install problem on windows 2000 March 2, 2006, 4:51 pm
Downgrade storable under Perl 5.8 August 6, 2006, 11:16 pm
problems with Memoize::Storable February 22, 2007, 4:54 pm
Bit::Vector objects serialized with Storable not working September 13, 2004, 3:15 am
Trouble installing storable 2.13 with perl 5.8.0 on redhat 9 machine December 10, 2004, 12:06 am
Where to get DBD::pg for Windows? January 12, 2005, 1:02 pm
Net::SFTP on Windows March 21, 2005, 9:55 pm
Windows: Perl:XS July 6, 2005, 4:57 am
Termcap under Windows XP... May 23, 2006, 1:49 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap