librelist archives

« back to archive

Flash from another thread

Flash from another thread

From:
Mr antback
Date:
2014-05-29 @ 19:56
Hi all,

In my application I have a long task that I start in a separated thead. I
would like to flash progress information from the new thread but the flash
message does not arrive into the application.
It is clear that the problem is about that the context of the new thread is
different, but I have seen the decorator @copy_current_request_context that
copies the application context into the new.
I have seen that is common its use for sending mails, like in this question:

http://stackoverflow.com/questions/11047307/run-flask-mail-asynchronously

My doubt is why it doesn't work with flash. What is what is really doing
the decorator?

Thanks a lot for your help.

PD: I have read a lot about this and people talk about celery, but in my
work I'm not allowed to install it.

Re: [flask] Flash from another thread

From:
Armin Ronacher
Date:
2014-05-30 @ 07:22
Hi,

On 30/05/2014 01:56, Mr antback wrote:
> In my application I have a long task that I start in a separated thead. I would
> like to flash progress information from the new thread but the flash message
> does not arrive into the application.
That will never be possible through the built-in system which flashes into a 
cookie which means that an HTTP response needs to be generated.

You might need to store the message in a database instead.


Regards,
Armin

Re: [flask] Flash from another thread

From:
Matthias Urlichs
Date:
2014-05-30 @ 07:49
Hi,

Armin Ronacher:
> You might need to store the message in a database instead.
> 
I'd investigate using something like socket.io.

-- 
-- Matthias Urlichs

Re: [flask] Flash from another thread

From:
Mr antback
Date:
2014-06-02 @ 07:49
Thanks for the responses. I will post my conclusion, if any.


On Fri, May 30, 2014 at 9:49 AM, Matthias Urlichs <matthias@urlichs.de>
wrote:

> Hi,
>
> Armin Ronacher:
> > You might need to store the message in a database instead.
> >
> I'd investigate using something like socket.io.
>
> --
> -- Matthias Urlichs
>