(busy) function call causes browser timeout

The error message that I am receiving is:

The page cannot be displayed

Explanation: The request timed out before the page could be retrieved.

Technical Information (for support personnel)

Error Code 1460: timeout

Background: The gateway could not receive a timely response from the
website you are trying to access, a DNS server, or another gateway
server. This might indicate that the network is congested or that the
website is experiencing technical difficulties.

I have an action that I added to Ticket_Overlay.pm that clones a current
ticket as many times as the user needs. It is called from Display.html
with the following code

elsif ( $ARGS{‘Action’} eq ‘Clone’ ) {

$TicketObj = LoadTicket($ARGS{'id'});

my $ticketIdStr;

unless ($TicketObj->CurrentUserHasRight('CreateTicket')){

Abort('You have no permission to create tickets in that queue.');

}

if (defined $ARGS{'many'}) {

        $ticketIdStr = $TicketObj->Clone($ARGS{'many'});

}else {

        $ticketIdStr = $TicketObj->Clone(1);

        }           

push @Actions, "Ticket(s) $ticketIdStr cloned from ticket

$ARGS{‘id’}";

$ARGS{'id'} = $TicketObj->id;

If I use Clone( ) to make a large number of tickets, the browser will
timeout before Clone() can return a value. Is there any way to thread
this or set a higher timeout value (not sure where this could be set)?
Not sure if I am posting to the right place, if not I will at least post
my Clone( ) code if anyone needs it or would like to critique. I
appreciate any suggestions!

This is the code I added to Ticket_Overlay.pm using RT ver.3.4:

=head2 Clone

Clones an existing ticket and its create transaction; returns the new
Ticket

object.

=cut

sub Clone {

my $self = shift;

my $many = shift;

        my $ret;

my $Requestor = split(",", $self->RequestorAddresses);

my $Cc = split(",", $self->CcAddresses);

my $AdminCc = split(",", $self->AdminCcAddresses);

my $transactions = RT::Transactions->new($self->CurrentUser);

$transactions->Limit( FIELD => ‘Ticket’, VALUE => $self->id() );

$transactions->Limit( FIELD => ‘Type’, VALUE => ‘Create’ );

my $attachment = $transactions->Next->Message->Next;

use MIME::Entity;

my $MIMEObj = MIME::Entity->build( Data => $attachment->Content,

map { /^([\w\-]+:)\s*(.*)$/; $1 => $2; } split(/\n/,

$attachment->Headers )

);

my $baseCFS = $self->CustomFields;

foreach my $tester($baseCFS) {

        $RT::Logger->debug("Tester check: " . $tester);

}

my @CFnames=();

my $count=0;

while (my $CF = $baseCFS->Next) {

$RT::Logger->debug("Checking Field: " . $CF->Name);

@CFnames[$count++] = $CF->Name;  

}

#$RT::Logger->debug (“We found a merged ticket.”. $self->id
."/".$self->EffectiveId);

$RT::Logger->debug (“Number to clone.”. $many);

for (my $i=0; $i<$many; $i++) {

        my $clone = RT::Ticket->new($self->CurrentUser); 

        my $OCFVObj =

RT::ObjectCustomFieldValue->new($self->CurrentUser);

        $clone->Create(

              Queue           => $self->Queue,

              Requestor       => $Requestor,

              Cc              => $Cc,

              AdminCc         => $AdminCc,

              Owner           => $self->Owner,

              Subject         => $self->Subject,

              InitialPriority => $self->InitialPriority,

              FinalPriority   => $self->FinalPriority,

              Priority        => $self->Priority,

              Status          => $self->Status,

              TimeWorked      => 0,

Type => $self->Type,

              Due             => $self->Due,

              #Created         => $self->Created,

              #Creator         => $self->Creator,

              MIMEObj         => $MIMEObj,

            ) or return 0;

        

                    foreach my $CFname(@CFnames) {

                                my $cfValues =

$self->CustomFieldValues($CFname);

                                while (my $CurrValue =

$cfValues->Next) {

                                            $OCFVObj->Create (

                                                        CustomField

=> $CurrValue->CustomField,

                                                        ObjectType

=> $CurrValue->ObjectType,

                                                        ObjectId =>

$clone->Id,

                                                        Disabled =>

‘0’,

                                                        Content =>

$CurrValue->Content,

                                                        LargeContent

=> ‘’,

                                                        ContentType

=> ‘’,

ContentEncoding => ‘’,

                                            );

                                } #end while

        

                    } # end foreach

                    if ($i == 0) {

                                $ret = $clone->id

                    }

                    else {

                                $ret = $ret . ", " .$clone->Id;

                    } 

}

return $ret;

}

###END OF CLONE()

And this little piece is added to /Ticket/Elements/Tabs:

if ($Ticket->CurrentUserHasRight(‘CreateTicket’)) {

$actions->{'Clone'} = 

  {

   title => 'Clone',

   path  => "Ticket/Display.html?Action=Clone&id=$id",

  };

}

The error message that I am receiving is:

The page cannot be displayed

Explanation: The request timed out before the page could be retrieved.

Technical Information (for support personnel)

Error Code 1460: timeout

Background: The gateway could not receive a timely response from the
website you are trying to access, a DNS server, or another gateway
server. This might indicate that the network is congested or that the
website is experiencing technical difficulties.

I have an action that I added to Ticket_Overlay.pm that clones a current
ticket as many times as the user needs. It is called from Display.html
with the following code

The browser is timing out waiting for the server to send
something (anything). I would do 2 things:

  1. Work on the making the clone process faster. (not easy)

  2. Rework the interface to that status information is periodically
    sent to the browser. This involves an occassional print (Or Mason
    output) and flushing the buffer.

-Todd

The error message that I am receiving is:

The page cannot be displayed

Explanation: The request timed out before the page could be
retrieved.

Technical Information (for support personnel)

Error Code 1460: timeout

Background: The gateway could not receive a timely response from the
website you are trying to access, a DNS server, or another gateway
server. This might indicate that the network is congested or that the
website is experiencing technical difficulties.

I have an action that I added to Ticket_Overlay.pm that clones a
current

ticket as many times as the user needs. It is called from
Display.html

with the following code

The browser is timing out waiting for the server to send
something (anything). I would do 2 things:

  1. Work on the making the clone process faster. (not easy)
  1. Rework the interface to that status information is periodically
    sent to the browser. This involves an occassional print (Or Mason
    output) and flushing the buffer.

-Todd

There are times where 100 or more tickets will have to be created, I
have a feeling I can never make it that fast. I research how to spit
Mason output and flushing the buffer, sounds like the right direction.
Thank you.

Ryan

There are times where 100 or more tickets will have to be created, I
have a feeling I can never make it that fast. I research how to spit
Mason output and flushing the buffer, sounds like the right direction.
Thank you.

Ryan

Here’s part of the answer: $m->flush_buffer();

There are times where 100 or more tickets will have to be created, I
have a feeling I can never make it that fast. I research how to spit
Mason output and flushing the buffer, sounds like the right
direction.

Thank you.

Ryan

Here’s part of the answer: $m->flush_buffer();

$m->out(…); for output :slight_smile: