librelist archives

« back to archive

Running an app on the background

Running an app on the background

From:
Btara Truhandarien
Date:
2014-01-23 @ 05:56
Hi I am very new to flask and so far have only really read the
documentations to help me start planning things out.

I was wondering whether an app can be run in the background.
The scenario I have in mind is the following:
The application I have will run for possibly a long time, but I do not want
the user having to wait for the application to finish running i.e I want
the users to be able to freely use other applications while this
application is running.

I was thinking that the user can be redirected to a page where it says that
the application is running and after the request, using after_request I can
run the application. I am not entirely sure however whether this is a
correct solution, nor the best solution. Any help is appreciated

Th

Re: [flask] Running an app on the background

From:
Hyunjun Kim
Date:
2014-01-23 @ 06:09
Hi,

You can make user be free during the time consuming task is running by 
throwing task to thread or task queue(check out Celery).
But there’s no way to notify user automatically after task done in Flask. 
You may have to implement it manually via server-sent events, websocket or
ajax polling to make user get notified or check periodically.

-- 
Hyunjun Kim
Sent with Airmail

켜짐 2014년 1월 23일 at 14:59:02, Btara Truhandarien 
(btara.truhandarien@gmail.com) 작성됨:

Hi I am very new to flask and so far have only really read the 
documentations to help me start planning things out.

I was wondering whether an app can be run in the background.
The scenario I have in mind is the following:
The application I have will run for possibly a long time, but I do not 
want the user having to wait for the application to finish running i.e I 
want the users to be able to freely use other applications while this 
application is running.

I was thinking that the user can be redirected to a page where it says 
that the application is running and after the request, using after_request
I can run the application. I am not entirely sure however whether this is 
a correct solution, nor the best solution. Any help is appreciated

Th

Re: [flask] Running an app on the background

From:
Btara Truhandarien
Date:
2014-01-23 @ 06:34
I looked up Celery and I'll give it a shot. I figured that Flask has no way
to automatically notify when a task is done, so I thought that I will just
keep a list of users running the app in a database. In the beginning I
didn't want users to be able to 're-run' the app i.e running the app again
even when their previous request has not finished. Though again I don't
know if using a database is the smartest thing to do. I did think of using
sessions.

A question regarding celery. Are there any potential hazardous situations
to watch out for when using celery for multiple users?


On Thu, Jan 23, 2014 at 1:09 PM, Hyunjun Kim <kim@hyunjun.kr> wrote:

> Hi,
>
> You can make user be free during the time consuming task is running by
> throwing task to thread or task queue(check out Celery).
> But there’s no way to notify user automatically after task done in Flask.
> You may have to implement it manually via serv er-sent events, websocket or
> ajax polling to make user get notified or check periodically.
>
> --
> Hyunjun Kim
> Sent with Airmail
>
> 켜짐 2014년 1월 23일 at 14:59:02, Btara Truhandarien (
> btara.truhandarien@gmail.com <//btara.truhandarien@gmail.com>) 작성됨:
>
> Hi I am very new to flask and so far have only really read the
> documentations to help me start planning things out.
>
> I was wondering whether an app can be run in the background.
> The scenario I have in mind is the following:
> The application I have will run for possibly a long time, but I do not
> want the user having to wait for the application to finish running i.e I
> want the users to be able to freely use other applications while this
> application is running.
>
> I was thinking that the user can be redirected to a page where it says
> that the application is running and after the request, using after_request
> I can run the application. I am not entirely sure however whether this is a
> correct solution, nor the best solution. Any help is appreciated
>
> Th
>
>

Re: [flask] Running an app on the background

From:
Hyunjun Kim
Date:
2014-01-23 @ 06:53
Celery environment is separated from http user session or flask, so the 
database or any kinds of storage is needed, of course it depends upon the 
kinds of work.

There’s no perplexing situations when using it for multiple users, but 
there are when using running multiple task workers. e.g. duplication of 
same works as you have mentioned.

Hyunjun Kim
Sent with Airmail

켜짐 2014년 1월 23일 at 15:36:16, Btara Truhandarien 
(btara.truhandarien@gmail.com) 작성됨:

I looked up Celery and I'll give it a shot. I figured that Flask has no 
way to automatically notify when a task is done, so I thought that I will 
just keep a list of users running the app in a database. In the beginning 
I didn't want users to be able to 're-run' the app i.e running the app 
again even when their previous request has not finished. Though again I 
don't know if using a database is the smartest thing to do. I did think of
using sessions.

A question regarding celery. Are there any potential hazardous situations 
to watch out for when using celery for multiple users?


On Thu, Jan 23, 2014 at 1:09 PM, Hyunjun Kim <kim@hyunjun.kr> wrote:
Hi,

You can make user be free during the time consuming task is running by 
throwing task to thread or task queue(check out Celery).
But there’s no way to notify user automatically after task done in Flask. 
You may have to implement it manually via serv er-sent events, websocket 
or ajax polling to make user get notified or check periodically.

-- 
Hyunjun Kim
Sent with Airmail

켜짐 2014년 1월 23일 at 14:59:02, Btara Truhandarien 
(btara.truhandarien@gmail.com) 작성됨:

Hi I am very new to flask and so far have only really read the 
documentations to help me start planning things out.

I was wondering whether an app can be run in the background.
The scenario I have in mind is the following:
The application I have will run for possibly a long time, but I do not 
want the user having to wait for the application to finish running i.e I 
want the users to be able to freely use other applications while this 
application is running.

I was thinking that the user can be redirected to a page where it says 
that the application is running and after the request, using after_request
I can run the application. I am not entirely sure however whether this is 
a correct solution, nor the best solution. Any help is appreciated

Th

Re: [flask] Running an app on the background

From:
Btara Truhandarien
Date:
2014-01-23 @ 07:59
Yes I'm reading further on Celery and so far what I understand is that if
the same application is ran and given to the Celery worker, that new
application will only run after the currently running task is finished. Is
this correct? And can a worker can do more than one task i.e multiprocess


On Thu, Jan 23, 2014 at 1:53 PM, Hyunjun Kim <kim@hyunjun.kr> wrote:

> Celery environment is separated from http user session or flask, so the
> database or any kinds of storage is needed, of course it depends upon the
> kinds of work.
>
> There’s no perplexing situations when using it for multiple users, but
> there are when using running multiple task workers. e.g. duplication of
> same works as you have mentioned.
>
> Hyunjun Kim
> Sent with Airmail
>
> 켜짐 2014년 1월 23일 at 15:36:16, Btara Truhandarien (
> btara.truhandarien@gmail.com <//btara.truhandarien@gmail.com>) 작성됨:
>
> I looked up Celery and I'll give it a shot. I figured that Flask has no
> way to automatically notify when a task is done, so I thought that I will
> just keep a list of users running the app in a database. In the beginning I
> didn't want users to be able to 're-run' the app i.e running the app again
> even when their previous request has not finished. Though again I don't
> know if using a database is the smartest thing to do. I did think of using
> sessions.
>
> A question regarding celery. Are there any potential hazardous situations
> to watch out for when using celery for multiple users?
>
>
> On Thu, Jan 23, 2014 at 1:09 PM, Hyunjun Kim <kim@hyunjun.kr> wrote:
>
>>  Hi,
>>
>>  You can make user be free during the time consuming task is running by
>> throwing task to thread or task queue(check out Celery).
>>  But there’s no way to notify user automatically after task done in
>> Flask. You may have to implement it manually via serv er-sent events,
>> websocket or ajax polling to make user get notified or check periodically.
>>
>> --
>> Hyunjun Kim
>> Sent with Airmail
>>
>> 켜짐 2014년 1월 23일 at 14:59:02, Btara Truhandarien (
>> btara.truhandarien@gmail.com <//btara.truhandarien@gmail.com>) 작성됨:
>>
>>  Hi I am very new to flask and so far have only really read the
>> documentations to help me start planning things out.
>>
>> I was wondering whether an app can be run in the background.
>> The scenario I have in mind is the following:
>> The application I have will run for possibly a long time, but I do not
>> want the user having to wait for the application to finish running i.e I
>> want the users to be able to freely use other applications while this
>> application is running.
>>
>> I was thinking that the user can be redirected to a page where it says
>> that the application is running and after the request, using after_request
>> I can run the application. I am not entirely sure however whether this is a
>> correct solution, nor the best solution. Any help is appreciated
>>
>> Th
>>
>>
>

Re: [flask] Running an app on the background

From:
Hyunjun Kim
Date:
2014-01-23 @ 08:40
You can run multiple Celery workers and each single worker support 
concurrency by processes, threads, gevent/eventlet.

http://docs.celeryproject.org/en/latest/configuration.html#celeryd-concurrency
http://docs.celeryproject.org/en/latest/configuration.html#celeryd-pool

-- 
Hyunjun Kim
Sent with Airmail

켜짐 2014년 1월 23일 at 17:01:25, Btara Truhandarien 
(btara.truhandarien@gmail.com) 작성됨:

Yes I'm reading further on Celery and so far what I understand is that if 
the same application is ran and given to the Celery worker, that new 
application will only run after the currently running task is finished. Is
this correct? And can a worker can do more than one task i.e multiprocess


On Thu, Jan 23, 2014 at 1:53 PM, Hyunjun Kim <kim@hyunjun.kr> wrote:
Celery environment is separated from http user session or flask, so the 
database or any kinds of storage is needed, of course it depends upon the 
kinds of work.

There’s no perplexing situations when using it for multiple users, but 
there are when using running multiple task workers. e.g. duplication of 
same works as you have mentioned.

Hyunjun Kim
Sent with Airmail

켜짐 2014년 1월 23일 at 15:36:16, Btara Truhandarien 
(btara.truhandarien@gmail.com) 작성됨:

I looked up Celery and I'll give it a shot. I figured that Flask has no 
way to automatically notify when a task is done, so I thought that I will 
just keep a list of users running the app in a database. In the beginning 
I didn't want users to be able to 're-run' the app i.e running the app 
again even when their previous request has not finished. Though again I 
don't know if using a database is the smartest thing to do. I did think of
using sessions.

A question regarding celery. Are there any potential hazardous situations 
to watch out for when using celery for multiple users?


On Thu, Jan 23, 2014 at 1:09 PM, Hyunjun Kim <kim@hyunjun.kr> wrote:
Hi,

You can make user be free during the time consuming task is running by 
throwing task to thread or task queue(check out Celery).
But there’s no way to notify user automatically after task done in Flask. 
You may have to implement it manually via serv er-sent events, websocket 
or ajax polling to make user get notified or check periodically.

-- 
Hyunjun Kim
Sent with Airmail

켜짐 2014년 1월 23일 at 14:59:02, Btara Truhandarien 
(btara.truhandarien@gmail.com) 작성됨:

Hi I am very new to flask and so far have only really read the 
documentations to help me start planning things out.

I was wondering whether an app can be run in the background.
The scenario I have in mind is the following:
The application I have will run for possibly a long time, but I do not 
want the user having to wait for the application to finish running i.e I 
want the users to be able to freely use other applications while this 
application is running.

I was thinking that the user can be redirected to a page where it says 
that the application is running and after the request, using after_request
I can run the application. I am not entirely sure however whether this is 
a correct solution, nor the best solution. Any help is appreciated

Th

Re: [flask] Running an app on the background

From:
Btara Truhandarien
Date:
2014-01-23 @ 09:25
Thank you.
One more question, can the method I thought of using after_request feasibly
work for the problem at hand?


On Thu, Jan 23, 2014 at 3:40 PM, Hyunjun Kim <kim@hyunjun.kr> wrote:

> You can run multiple Celery workers and each single worker support
> concurrency by processes, threads, gevent/eventlet.
>
>
> http://docs.celeryproject.org/en/latest/configuration.html#celeryd-concurrency
> http://docs.celeryproject.org/en/latest/configuration.html#celeryd-pool
>
> --
> Hyunjun Kim
> Sent with Airmail
>
> 켜짐 2014년 1월 23일 at 17:01:25, Btara Truhandarien (
> btara.truhandarien@gmail.com <//btara.truhandarien@gmail.com>) 작성됨:
>
> Yes I'm reading further on Celery and so far what I understand is that if
> the same application is ran and given to the Celery worker, that new
> application will only run after the currently running task is finished. Is
> this correct? And can a worker can do more than one task i.e multiprocess
>
>
> On Thu, Jan 23, 2014 at 1:53 PM, Hyunjun Kim <kim@hyunjun.kr> wrote:
>
>>  Celery environment is separated from http user session or flask, so the
>> database or any kinds of storage is needed, of course it depends upon the
>> kinds of work.
>>
>>  There’s no perplexing situations when using it for multiple users, but
>> there are when using running multiple task workers. e.g. duplication of
>> same works as you have mentioned.
>>
>> Hyunjun Kim
>> Sent with Airmail
>>
>> 켜짐 2014년 1월 23일 at 15:36:16, Btara Truhandarien (
>> btara.truhandarien@gmail.com <//btara.truhandarien@gmail.com>) 작성됨:
>>
>>  I looked up Celery and I'll give it a shot. I figured that Flask has no
>> way to automatically notify when a task is done, so I thought that I will
>> just keep a list of users running the app in a database. In the beginning I
>> didn't want users to be able to 're-run' the app i.e running the app again
>> even when their previous request has not finished. Though again I don't
>> know if using a database is the smartest thing to do. I did think of using
>> sessions.
>>
>> A question regarding celery. Are there any potential hazardous situations
>> to watch out for when using celery for multiple users?
>>
>>
>> On Thu, Jan 23, 2014 at 1:09 PM, Hyunjun Kim <kim@hyunjun.kr> wrote:
>>
>>>  Hi,
>>>
>>>  You can make user be free during the time consuming task is running by
>>> throwing task to thread or task queue(check out Celery).
>>>  But there’s no way to notify user automatically after task done in
>>> Flask. You may have to implement it manually via serv er-sent events,
>>> websocket or ajax polling to make user get notified or check periodically.
>>>
>>> --
>>> Hyunjun Kim
>>> Sent with Airmail
>>>
>>> 켜짐 2014년 1월 23일 at 14:59:02, Btara Truhandarien (
>>> btara.truhandarien@gmail.com <//btara.truhandarien@gmail.com>) 작성됨:
>>>
>>>  Hi I am very new to flask and so far have only really read the
>>> documentations to help me start planning things out.
>>>
>>> I was wondering whether an app can be run in the background.
>>> The scenario I have in mind is the following:
>>> The application I have will run for possibly a long time, but I do not
>>> want the user having to wait for the application to finish running i.e I
>>> want the users to be able to freely use other applications while this
>>> application is running.
>>>
>>> I was thinking that the user can be redirected to a page where it says
>>> that the application is running and after the request, using after_request
>>> I can run the application. I am not entirely sure however whether this is a
>>> correct solution, nor the best solution. Any help is appreciated
>>>
>>> Th
>>>
>>>
>>
>

Re: [flask] Running an app on the background

From:
Hyunjun Kim
Date:
2014-01-23 @ 09:37
You should implement it as far as I know. after_request is the signal used
for processing single HTTP request.

-- 
Hyunjun Kim
Sent with Airmail

켜짐 2014년 1월 23일 at 18:27:19, Btara Truhandarien 
(btara.truhandarien@gmail.com) 작성됨:

Thank you.
One more question, can the method I thought of using after_request 
feasibly work for the problem at hand?


On Thu, Jan 23, 2014 at 3:40 PM, Hyunjun Kim <kim@hyunjun.kr> wrote:
You can run multiple Celery workers and each single worker support 
concurrency by processes, threads, gevent/eventlet.

http://docs.celeryproject.org/en/latest/configuration.html#celeryd-concurrency
http://docs.celeryproject.org/en/latest/configuration.html#celeryd-pool

-- 
Hyunjun Kim
Sent with Airmail

켜짐 2014년 1월 23일 at 17:01:25, Btara Truhandarien 
(btara.truhandarien@gmail.com) 작성됨:

Yes I'm reading further on Celery and so far what I understand is that if 
the same application is ran and given to the Celery worker, that new 
application will only run after the currently running task is finished. Is
this correct? And can a worker can do more than one task i.e multiprocess


On Thu, Jan 23, 2014 at 1:53 PM, Hyunjun Kim <kim@hyunjun.kr> wrote:
Celery environment is separated from http user session or flask, so the 
database or any kinds of storage is needed, of course it depends upon the 
kinds of work.

There’s no perplexing situations when using it for multiple users, but 
there are when using running multiple task workers. e.g. duplication of 
same works as you have mentioned.

Hyunjun Kim
Sent with Airmail

켜짐 2014년 1월 23일 at 15:36:16, Btara Truhandarien 
(btara.truhandarien@gmail.com) 작성됨:

I looked up Celery and I'll give it a shot. I figured that Flask has no 
way to automatically notify when a task is done, so I thought that I will 
just keep a list of users running the app in a database. In the beginning 
I didn't want users to be able to 're-run' the app i.e running the app 
again even when their previous request has not finished. Though again I 
don't know if using a database is the smartest thing to do. I did think of
using sessions.

A question regarding celery. Are there any potential hazardous situations 
to watch out for when using celery for multiple users?


On Thu, Jan 23, 2014 at 1:09 PM, Hyunjun Kim <kim@hyunjun.kr> wrote:
Hi,

You can make user be free during the time consuming task is running by 
throwing task to thread or task queue(check out Celery).
But there’s no way to notify user automatically after task done in Flask. 
You may have to implement it manually via serv er-sent events, websocket 
or ajax polling to make user get notified or check periodically.

-- 
Hyunjun Kim
Sent with Airmail

켜짐 2014년 1월 23일 at 14:59:02, Btara Truhandarien 
(btara.truhandarien@gmail.com) 작성됨:

Hi I am very new to flask and so far have only really read the 
documentations to help me start planning things out.

I was wondering whether an app can be run in the background.
The scenario I have in mind is the following:
The application I have will run for possibly a long time, but I do not 
want the user having to wait for the application to finish running i.e I 
want the users to be able to freely use other applications while this 
application is running.

I was thinking that the user can be redirected to a page where it says 
that the application is running and after the request, using after_request
I can run the application. I am not entirely sure however whether this is 
a correct solution, nor the best solution. Any help is appreciated

Th


Re: [flask] Running an app on the background

From:
Btara Truhandarien
Date:
2014-01-23 @ 11:13
Any idea if it will enable multiple sessions of the same application to be
run on the background?


On Thu, Jan 23, 2014 at 4:37 PM, Hyunjun Kim <kim@hyunjun.kr> wrote:

> You should implement it as far as I know. after_request is the signal used
> for processing single HTTP request.
>
> --
> Hyunjun Kim
> Sent with Airmail
>
> 켜짐 2014년 1월 23일 at 18:27:19, Btara Truhandarien (
> btara.truhandarien@gmail.com <//btara.truhandarien@gmail.com>) 작성됨:
>
> Thank you.
> One more question, can the method I thought of using after_request
> feasibly work for the problem at hand?
>
>
> On Thu, Jan 23, 2014 at 3:40 PM, Hyunjun Kim <kim@hyunjun.kr> wrote:
>
>>  You can run multiple Celery workers and each single worker support
>> concurrency by processes, threads, gevent/eventlet.
>>
>>
>> http://docs.celeryproject.org/en/latest/configuration.html#celeryd-concurrency
>> http://docs.celeryproject.org/en/latest/configuration.html#celeryd-pool
>>
>> --
>> Hyunjun Kim
>> Sent with Airmail
>>
>> 켜짐 2014년 1월 23일 at 17:01:25, Btara Truhandarien (
>> btara.truhandarien@gmail.com <//btara.truhandarien@gmail.com>) 작성됨:
>>
>>  Yes I'm reading further on Celery and so far what I understand is that
>> if the same application is ran and given to the Celery worker, that new
>> application will only run after the currently running task is finished. Is
>> this correct? And can a worker can do more than one task i.e multiprocess
>>
>>
>> On Thu, Jan 23, 2014 at 1:53 PM, Hyunjun Kim <kim@hyunjun.kr> wrote:
>>
>>>  Celery environment is separated from http user session or flask, so
>>> the database or any kinds of storage is needed, of course it depends upon
>>> the kinds of work.
>>>
>>>  There’s no perplexing situations when using it for multiple users, but
>>> there are when using running multiple task workers. e.g. duplication of
>>> same works as you have mentioned.
>>>
>>> Hyunjun Kim
>>> Sent with Airmail
>>>
>>> 켜짐 2014년 1월 23일 at 15:36:16, Btara Truhandarien (
>>> btara.truhandarien@gmail.com <//btara.truhandarien@gmail.com>) 작성됨:
>>>
>>>  I looked up Celery and I'll give it a shot. I figured that Flask has
>>> no way to automatically notify when a task is done, so I thought that I
>>> will just keep a list of users running the app in a database. In the
>>> beginning I didn't want users to be able to 're-run' the app i.e running
>>> the app again even when their previous request has not finished. Though
>>> again I don't know if using a database is the smartest thing to do. I did
>>> think of using sessions.
>>>
>>> A question regarding celery. Are there any potential hazardous
>>> situations to watch out for when using celery for multiple users?
>>>
>>>
>>> On Thu, Jan 23, 2014 at 1:09 PM, Hyunjun Kim <kim@hyunjun.kr> wrote:
>>>
>>>>  Hi,
>>>>
>>>>  You can make user be free during the time consuming task is running by
>>>> throwing task to thread or task queue(check out Celery).
>>>>  But there’s no way to notify user automatically after task done in
>>>> Flask. You may have to implement it manually via serv er-sent events,
>>>> websocket or ajax polling to make user get notified or check periodically.
>>>>
>>>> --
>>>> Hyunjun Kim
>>>> Sent with Airmail
>>>>
>>>> 켜짐 2014년 1월 23일 at 14:59:02, Btara Truhandarien (
>>>> btara.truhandarien@gmail.com <//btara.truhandarien@gmail.com>) 작성됨:
>>>>
>>>>  Hi I am very new to flask and so far have only really read the
>>>> documentations to help me start planning things out.
>>>>
>>>> I was wondering whether an app can be run in the background.
>>>> The scenario I have in mind is the following:
>>>> The application I have will run for possibly a long time, but I do not
>>>> want the user having to wait for the application to finish running i.e I
>>>> want the users to be able to freely use other applications while this
>>>> application is running.
>>>>
>>>> I was thinking that the user can be redirected to a page where it says
>>>> that the application is running and after the request, using after_request
>>>> I can run the application. I am not entirely sure however whether this is a
>>>> correct solution, nor the best solution. Any help is appreciated
>>>>
>>>> Th
>>>>
>>>>
>>>
>>
>