backport DXSubprocess to change serialisations

Currently the internals of Mojo::IOLoop::Subprocess defaults to
using Storaable as its cross-process argument and data serialisaion
method. It can use others. This update reverts back to the
original ForkCall method of using JSON.
This commit is contained in:
Dirk Koopman 2020-05-17 11:28:40 +01:00
parent 3b932bf2af
commit 9d190c7619
5 changed files with 36 additions and 7 deletions

View File

@ -1,3 +1,9 @@
17May20=======================================================================
1. Backport DXSubprocess to change serialisations.
Currently the internals of Mojo::IOLoop::Subprocess defaults to
using Storeable as its cross-process argument and data serialisaion
method. It can use others. This update reverts back to the
original ForkCall method of using JSON.
10May20=======================================================================
1. Added basic changes so that users *could* have multiple connections to the
same node if it is allowed. This is work in progress and is there to see

View File

@ -43,7 +43,7 @@ use JSON;
use Time::HiRes qw(gettimeofday tv_interval);
use Mojo::IOLoop;
use Mojo::IOLoop::Subprocess;
use DXSubprocess;
use Mojo::UserAgent;
use strict;
@ -1316,7 +1316,7 @@ sub spawn_cmd
return @out;
}
my $fc = Mojo::IOLoop::Subprocess->new;
my $fc = DXSubprocess->new;
# $fc->serializer(\&encode_json);
# $fc->deserializer(\&decode_json);
$fc->run(

View File

@ -15,7 +15,7 @@ use DXDebug;
use IO::File;
use DXLog;
use Time::HiRes qw(gettimeofday tv_interval);
use Mojo::IOLoop::Subprocess;
use DXSubprocess;
use strict;
@ -257,7 +257,7 @@ sub spawn
my $t0 = [gettimeofday];
dbg("DXCron::spawn: $line") if isdbg("cron");
my $fc = Mojo::IOLoop::Subprocess->new();
my $fc = DXSubprocess->new();
$fc->run(
sub {
my @res = `$line`;
@ -286,7 +286,7 @@ sub spawn_cmd
my $t0 = [gettimeofday];
dbg("DXCron::spawn_cmd run: $line") if isdbg('cron');
my $fc = Mojo::IOLoop::Subprocess->new();
my $fc = DXSubprocess->new();
$fc->run(
sub {
$main::me->{_nospawn} = 1;

View File

@ -35,7 +35,7 @@ use Script;
use DXProtHandle;
use Time::HiRes qw(gettimeofday tv_interval);
use Mojo::IOLoop::Subprocess;
use DXSubprocess;
use strict;
@ -1216,7 +1216,7 @@ sub spawn_cmd
no strict 'refs';
my $fc = Mojo::IOLoop::Subprocess->new;
my $fc = DXSubprocess->new;
# just behave normally if something has set the "one-shot" _nospawn in the channel
if ($self->{_nospawn}) {

23
perl/DXSubprocess.pm Normal file
View File

@ -0,0 +1,23 @@
#
# A light shim over Mojo::IOLoop::Subprocess (or Mojo::IOLoop::ForkCall, if we need to go back to that)
#
# But we stop using Storable!
#
package DXSubprocess;
use DXUtil;
use DXDebug;
use Mojo::IOLoop;
use Mojo::IOLoop::Subprocess;
use JSON;
our @ISA = qw(Mojo::IOLoop::Subprocess);
sub new
{
my $pkg = shift;
my $class = ref $pkg || __PACKAGE__;
my $ref = Mojo::IOLoop::Subprocess->new->serialize(\&encode_json)->deserialize(\&decode_json);
return bless $ref, $class;
}