Problem with Mojo::IOLoop timer before redirectOutput command to socket without buffering using Mojo::IOLoopWhy separate routing and controller actions in mojolicious?Route to static file in MojoMojo IOLoop blocks app when ranShutting down a Mojo::IOLoop recurring event connected to a Mojo websocketMojo::UserAgent clear session dataMojo::DOM manipulationSequentioal requests with Mojo::IOLoop::Delayunderstanding Mojo::IOLoop recurring and subprocessCan I limit the number of connections for Mojo::IOLoop?
Is a naturally all "male" species possible?
Books on the History of math research at European universities
Lifted its hind leg on or lifted its hind leg towards?
Who must act to prevent Brexit on March 29th?
How will losing mobility of one hand affect my career as a programmer?
Is there an Impartial Brexit Deal comparison site?
Female=gender counterpart?
For airliners, what prevents wing strikes on landing in bad weather?
Is there an wasy way to program in Tikz something like the one in the image?
Why are all the doors on Ferenginar (the Ferengi home world) far shorter than the average Ferengi?
Why isn't KTEX's runway designation 10/28 instead of 9/27?
Blender - show edges angles “direction”
Identify a stage play about a VR experience in which participants are encouraged to simulate performing horrific activities
My boss asked me to take a one-day class, then signs it up as a day off
Simple recursive Sudoku solver
Are Warlocks Arcane or Divine?
Proof of Lemma: Every integer can be written as a product of primes
Superhero words!
Why is delta-v is the most useful quantity for planning space travel?
Pronouncing Homer as in modern Greek
Simulating a probability of 1 of 2^N with less than N random bits
Can the electrostatic force be infinite in magnitude?
A workplace installs custom certificates on personal devices, can this be used to decrypt HTTPS traffic?
Is it legal to discriminate due to the medicine used to treat a medical condition?
Problem with Mojo::IOLoop timer before redirect
Output command to socket without buffering using Mojo::IOLoopWhy separate routing and controller actions in mojolicious?Route to static file in MojoMojo IOLoop blocks app when ranShutting down a Mojo::IOLoop recurring event connected to a Mojo websocketMojo::UserAgent clear session dataMojo::DOM manipulationSequentioal requests with Mojo::IOLoop::Delayunderstanding Mojo::IOLoop recurring and subprocessCan I limit the number of connections for Mojo::IOLoop?
i have a sub in my Mojolicious Controller which is called when a csv file is uploaded through a http post.
After the file is uploaded, a message gets rendered that say "you will be redirected in x seconds".
so i want to implement Mojo::IOLoop::Delay and as callback i use the redirect statement. But i get the following error by Morbo:
Mojo::Reactor::EV: Timer failed: Transaction already destroyed at /usr/local/share/perl/5.22.1/Mojolicious/Plugin/DefaultHelpers.pm line 168.
controller code:
sub upload
my $self = shift;
# Check file size
return $self->render(text => 'File is too big.', status => 200)
if $self->req->is_limit_exceeded;
# Process uploaded file
return $self->redirect_to('/') unless my $newCsv = $self->param('fileToUpload');
my $size = $newCsv->size;
my $name = $newCsv->filename;
my $delay = 2;
$self->render(text => "Thanks for uploading $size byte file $name.<br>
You will be redirected in $delay seconds");
Mojo::IOLoop->timer($delay => sub
$self->redirect_to('/');
);
relevant routes:
$r->get('/')->to(controller => 'main', action => 'index');
$r->post('/uploadCsv')->to(controller => 'main', action => 'upload')->name('uploadCsv');
Thank you in advance
perl mojolicious morbo
add a comment |
i have a sub in my Mojolicious Controller which is called when a csv file is uploaded through a http post.
After the file is uploaded, a message gets rendered that say "you will be redirected in x seconds".
so i want to implement Mojo::IOLoop::Delay and as callback i use the redirect statement. But i get the following error by Morbo:
Mojo::Reactor::EV: Timer failed: Transaction already destroyed at /usr/local/share/perl/5.22.1/Mojolicious/Plugin/DefaultHelpers.pm line 168.
controller code:
sub upload
my $self = shift;
# Check file size
return $self->render(text => 'File is too big.', status => 200)
if $self->req->is_limit_exceeded;
# Process uploaded file
return $self->redirect_to('/') unless my $newCsv = $self->param('fileToUpload');
my $size = $newCsv->size;
my $name = $newCsv->filename;
my $delay = 2;
$self->render(text => "Thanks for uploading $size byte file $name.<br>
You will be redirected in $delay seconds");
Mojo::IOLoop->timer($delay => sub
$self->redirect_to('/');
);
relevant routes:
$r->get('/')->to(controller => 'main', action => 'index');
$r->post('/uploadCsv')->to(controller => 'main', action => 'upload')->name('uploadCsv');
Thank you in advance
perl mojolicious morbo
add a comment |
i have a sub in my Mojolicious Controller which is called when a csv file is uploaded through a http post.
After the file is uploaded, a message gets rendered that say "you will be redirected in x seconds".
so i want to implement Mojo::IOLoop::Delay and as callback i use the redirect statement. But i get the following error by Morbo:
Mojo::Reactor::EV: Timer failed: Transaction already destroyed at /usr/local/share/perl/5.22.1/Mojolicious/Plugin/DefaultHelpers.pm line 168.
controller code:
sub upload
my $self = shift;
# Check file size
return $self->render(text => 'File is too big.', status => 200)
if $self->req->is_limit_exceeded;
# Process uploaded file
return $self->redirect_to('/') unless my $newCsv = $self->param('fileToUpload');
my $size = $newCsv->size;
my $name = $newCsv->filename;
my $delay = 2;
$self->render(text => "Thanks for uploading $size byte file $name.<br>
You will be redirected in $delay seconds");
Mojo::IOLoop->timer($delay => sub
$self->redirect_to('/');
);
relevant routes:
$r->get('/')->to(controller => 'main', action => 'index');
$r->post('/uploadCsv')->to(controller => 'main', action => 'upload')->name('uploadCsv');
Thank you in advance
perl mojolicious morbo
i have a sub in my Mojolicious Controller which is called when a csv file is uploaded through a http post.
After the file is uploaded, a message gets rendered that say "you will be redirected in x seconds".
so i want to implement Mojo::IOLoop::Delay and as callback i use the redirect statement. But i get the following error by Morbo:
Mojo::Reactor::EV: Timer failed: Transaction already destroyed at /usr/local/share/perl/5.22.1/Mojolicious/Plugin/DefaultHelpers.pm line 168.
controller code:
sub upload
my $self = shift;
# Check file size
return $self->render(text => 'File is too big.', status => 200)
if $self->req->is_limit_exceeded;
# Process uploaded file
return $self->redirect_to('/') unless my $newCsv = $self->param('fileToUpload');
my $size = $newCsv->size;
my $name = $newCsv->filename;
my $delay = 2;
$self->render(text => "Thanks for uploading $size byte file $name.<br>
You will be redirected in $delay seconds");
Mojo::IOLoop->timer($delay => sub
$self->redirect_to('/');
);
relevant routes:
$r->get('/')->to(controller => 'main', action => 'index');
$r->post('/uploadCsv')->to(controller => 'main', action => 'upload')->name('uploadCsv');
Thank you in advance
perl mojolicious morbo
perl mojolicious morbo
edited Mar 8 at 18:00
Grinnz
3,311514
3,311514
asked Mar 8 at 8:10
ChrisChris
376114
376114
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
upload
returns after Mojo::IOLoop->timer
and nothing waits for the timer. You can try using Mojo::IOLoop->delay and $delay->wait
instead. But I am not sure how it works. So it might be equivalent to just sleep
.
Do you really need to redirect from perl code? You can render some js with setTimeout
for the same effect.
In fact I would recommend moving all text and redirecting to js and render only json with some status information inside upload
. So you can implement better UI with error handling.
add a comment |
redirect_to
is effectively a render
that renders a HTTP 302 response to redirect. You cannot render twice, so even if you keep the transaction around until the redirect_to
call, it would have already rendered the page. So there are two actual options for what you are trying to do; render a page with javascript that will perform the redirect after a timeout, or render an HTML page with a meta refresh tag which will cause the page to redirect after a delay. This MDN page discusses both approaches.
thanks for your answer. I have chosen the 3rd solution :) : i implemented a JS-script with a timeout in my .html. do you think this solution is practicable too, or it's not "the best" solution?
– Chris
Mar 8 at 20:33
@Chris I think it's fine for what you want to accomplish, the only benefit of the meta-refresh approach is that it doesn't require the user to enable javascript.
– Grinnz
Mar 8 at 20:36
i see, thanks again for your support!
– Chris
Mar 8 at 20:42
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55059064%2fproblem-with-mojoioloop-timer-before-redirect%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
upload
returns after Mojo::IOLoop->timer
and nothing waits for the timer. You can try using Mojo::IOLoop->delay and $delay->wait
instead. But I am not sure how it works. So it might be equivalent to just sleep
.
Do you really need to redirect from perl code? You can render some js with setTimeout
for the same effect.
In fact I would recommend moving all text and redirecting to js and render only json with some status information inside upload
. So you can implement better UI with error handling.
add a comment |
upload
returns after Mojo::IOLoop->timer
and nothing waits for the timer. You can try using Mojo::IOLoop->delay and $delay->wait
instead. But I am not sure how it works. So it might be equivalent to just sleep
.
Do you really need to redirect from perl code? You can render some js with setTimeout
for the same effect.
In fact I would recommend moving all text and redirecting to js and render only json with some status information inside upload
. So you can implement better UI with error handling.
add a comment |
upload
returns after Mojo::IOLoop->timer
and nothing waits for the timer. You can try using Mojo::IOLoop->delay and $delay->wait
instead. But I am not sure how it works. So it might be equivalent to just sleep
.
Do you really need to redirect from perl code? You can render some js with setTimeout
for the same effect.
In fact I would recommend moving all text and redirecting to js and render only json with some status information inside upload
. So you can implement better UI with error handling.
upload
returns after Mojo::IOLoop->timer
and nothing waits for the timer. You can try using Mojo::IOLoop->delay and $delay->wait
instead. But I am not sure how it works. So it might be equivalent to just sleep
.
Do you really need to redirect from perl code? You can render some js with setTimeout
for the same effect.
In fact I would recommend moving all text and redirecting to js and render only json with some status information inside upload
. So you can implement better UI with error handling.
answered Mar 8 at 8:30
UjinT34UjinT34
1,766112
1,766112
add a comment |
add a comment |
redirect_to
is effectively a render
that renders a HTTP 302 response to redirect. You cannot render twice, so even if you keep the transaction around until the redirect_to
call, it would have already rendered the page. So there are two actual options for what you are trying to do; render a page with javascript that will perform the redirect after a timeout, or render an HTML page with a meta refresh tag which will cause the page to redirect after a delay. This MDN page discusses both approaches.
thanks for your answer. I have chosen the 3rd solution :) : i implemented a JS-script with a timeout in my .html. do you think this solution is practicable too, or it's not "the best" solution?
– Chris
Mar 8 at 20:33
@Chris I think it's fine for what you want to accomplish, the only benefit of the meta-refresh approach is that it doesn't require the user to enable javascript.
– Grinnz
Mar 8 at 20:36
i see, thanks again for your support!
– Chris
Mar 8 at 20:42
add a comment |
redirect_to
is effectively a render
that renders a HTTP 302 response to redirect. You cannot render twice, so even if you keep the transaction around until the redirect_to
call, it would have already rendered the page. So there are two actual options for what you are trying to do; render a page with javascript that will perform the redirect after a timeout, or render an HTML page with a meta refresh tag which will cause the page to redirect after a delay. This MDN page discusses both approaches.
thanks for your answer. I have chosen the 3rd solution :) : i implemented a JS-script with a timeout in my .html. do you think this solution is practicable too, or it's not "the best" solution?
– Chris
Mar 8 at 20:33
@Chris I think it's fine for what you want to accomplish, the only benefit of the meta-refresh approach is that it doesn't require the user to enable javascript.
– Grinnz
Mar 8 at 20:36
i see, thanks again for your support!
– Chris
Mar 8 at 20:42
add a comment |
redirect_to
is effectively a render
that renders a HTTP 302 response to redirect. You cannot render twice, so even if you keep the transaction around until the redirect_to
call, it would have already rendered the page. So there are two actual options for what you are trying to do; render a page with javascript that will perform the redirect after a timeout, or render an HTML page with a meta refresh tag which will cause the page to redirect after a delay. This MDN page discusses both approaches.
redirect_to
is effectively a render
that renders a HTTP 302 response to redirect. You cannot render twice, so even if you keep the transaction around until the redirect_to
call, it would have already rendered the page. So there are two actual options for what you are trying to do; render a page with javascript that will perform the redirect after a timeout, or render an HTML page with a meta refresh tag which will cause the page to redirect after a delay. This MDN page discusses both approaches.
answered Mar 8 at 17:52
GrinnzGrinnz
3,311514
3,311514
thanks for your answer. I have chosen the 3rd solution :) : i implemented a JS-script with a timeout in my .html. do you think this solution is practicable too, or it's not "the best" solution?
– Chris
Mar 8 at 20:33
@Chris I think it's fine for what you want to accomplish, the only benefit of the meta-refresh approach is that it doesn't require the user to enable javascript.
– Grinnz
Mar 8 at 20:36
i see, thanks again for your support!
– Chris
Mar 8 at 20:42
add a comment |
thanks for your answer. I have chosen the 3rd solution :) : i implemented a JS-script with a timeout in my .html. do you think this solution is practicable too, or it's not "the best" solution?
– Chris
Mar 8 at 20:33
@Chris I think it's fine for what you want to accomplish, the only benefit of the meta-refresh approach is that it doesn't require the user to enable javascript.
– Grinnz
Mar 8 at 20:36
i see, thanks again for your support!
– Chris
Mar 8 at 20:42
thanks for your answer. I have chosen the 3rd solution :) : i implemented a JS-script with a timeout in my .html. do you think this solution is practicable too, or it's not "the best" solution?
– Chris
Mar 8 at 20:33
thanks for your answer. I have chosen the 3rd solution :) : i implemented a JS-script with a timeout in my .html. do you think this solution is practicable too, or it's not "the best" solution?
– Chris
Mar 8 at 20:33
@Chris I think it's fine for what you want to accomplish, the only benefit of the meta-refresh approach is that it doesn't require the user to enable javascript.
– Grinnz
Mar 8 at 20:36
@Chris I think it's fine for what you want to accomplish, the only benefit of the meta-refresh approach is that it doesn't require the user to enable javascript.
– Grinnz
Mar 8 at 20:36
i see, thanks again for your support!
– Chris
Mar 8 at 20:42
i see, thanks again for your support!
– Chris
Mar 8 at 20:42
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55059064%2fproblem-with-mojoioloop-timer-before-redirect%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown