App-MtAws

 view release on metacpan or  search on metacpan

lib/App/MtAws/HttpSegmentWriter.pm  view on Meta::CPAN

	sleep 2;
	confess @_;
}


sub new
{
	my ($class, %args) = @_;
	my $self = \%args;
	bless $self, $class;
	$self->SUPER::initialize();
	$self->initialize();
	return $self;
}

sub initialize
{
	my ($self) = @_;
	defined($self->{filename}) or confess;
	defined($self->{tempfile}) or confess;
	defined($self->{position}) or confess;
}

sub reinit
{
	my $self = shift;
	$self->{incr_position} = 0;
	$self->{treehash} = App::MtAws::TreeHash->new();
	$self->SUPER::reinit(@_);
}

sub treehash { shift->{treehash} }

sub _flush
{
	my ($self) = @_;
	if ($self->{pending_length}) {
		open_file(my $fh, $self->{tempfile}, mode => '+<', binary => 1) or delayed_confess "cant open file $self->{tempfile} $!";
		flock $fh, LOCK_EX or delayed_confess;

lib/App/MtAws/HttpSegmentWriter.pm  view on Meta::CPAN

		$fh->autoflush(1);
		seek $fh, $self->{position}+$self->{incr_position}, SEEK_SET or delayed_confess "cannot seek() $!";
		$self->{incr_position} += $self->_flush_buffers($fh);
		close $fh or delayed_confess; # close will unlock
	}
}

sub finish
{
	my ($self) = @_;
	my @r = $self->SUPER::finish();
	return @r;
}


package App::MtAws::HttpFileWriter;

our $VERSION = '1.120';

use strict;
use warnings;

lib/App/MtAws/HttpSegmentWriter.pm  view on Meta::CPAN

use App::MtAws::Utils;
use Carp;
use base qw/App::MtAws::HttpWriter/;


sub new
{
	my ($class, %args) = @_;
	my $self = \%args;
	bless $self, $class;
	$self->SUPER::initialize();
	$self->initialize();
	return $self;
}

sub initialize
{
	my ($self) = @_;
	defined($self->{tempfile}) or confess;
}

sub reinit
{
	my $self = shift;
	undef $self->{fh};
	open_file($self->{fh}, $self->{tempfile}, mode => '+<', binary => 1) or confess "cant open file $self->{tempfile} $!";
	binmode $self->{fh};
	$self->{treehash} = App::MtAws::TreeHash->new();
	$self->SUPER::reinit(@_);
}

sub treehash { shift->{treehash} }

sub _flush
{
	my ($self) = @_;
	if ($self->{pending_length}) {
		$self->_flush_buffers($self->{fh});
	}
}

sub finish
{
	my ($self) = @_;
	my @r = $self->SUPER::finish();
	close $self->{fh} or confess;
	return @r;
}


package App::MtAws::HttpMemoryWriter;

our $VERSION = '1.120';

use strict;

t/lib/MyQueueEngine.pm  view on Meta::CPAN

	no strict 'refs';

	my @r = $self->$method(%{$task->{args}});
	$task->{cb_task_proxy}->(@r);
}

sub process
{
	my $self = shift;
	alarm 60; # protecting in case test fail and all stuck
	$self->SUPER::process(@_);
	alarm 0;
}

1;

t/unit/queue_job/fetch_and_download.t  view on Meta::CPAN


{
	package QE;
	use MyQueueEngine;
	use base q{MyQueueEngine};

	sub new
	{
		my $class = shift;
		my $E = shift;
		my $self = $class->SUPER::new(@_);
		$self->{_E} = $E;
		$self;
	}

	sub on_retrieval_fetch_job
	{
		my ($self, %args) = @_;
		my $page = $self->{_E}->fetch_page($args{marker});
		{ response => $page };
	}



( run in 0.409 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )