librelist archives

« back to archive

embeded queue

embeded queue

From:
bino oetomo
Date:
2014-08-07 @ 09:22
Dear all

I need a simple 'internal' job queue for my existing flask based Restful
service.
more or less, my try just like
http://pastebin.com/HSgb9pSJ
(note : I name it que01.py)

when I run above script in one terminal, and run
http://pastebin.com/aHpP0f0V to test it ... it works just fine, i test it
using --> curl -i http://localhost:5000/len


But when I run it using wsgi server ( gunicorn -b 0.0.0.0:5000 que01:app
), I realize it that parts starting from 'if __name__ == '__main__':
' is NOT called.

So my question is there any job queueing system that can be embeded into
existing flask-based restful service ?

Note : in my existing flask script ... most time will not need this queue,
but some time it'll needed

Sincerely
-bino-

Re: [flask] embeded queue

From:
Matt Smith
Date:
2014-08-07 @ 09:50
You application is being imported and run with Gunicorn,
I believe with gunicorn you are meant to expose just an 'app' variable
which will be called to start your server.

To start the queue you should just move it out of the ifmain.


*Regards,*
*Matt Smith*Summoner: *PsyKzz* | *@**PsyKzz*



On 7 August 2014 10:22, bino oetomo <bino@indoakses-online.com> wrote:

> Dear all
>
> I need a simple 'internal' job queue for my existing flask based Restful
> service.
> more or less, my try just like
> http://pastebin.com/HSgb9pSJ
> (note : I name it que01.py)
>
> when I run above script in one terminal, and run
> http://pastebin.com/aHpP0f0V to test it ... it works just fine, i test it
> using --> curl -i http://localhost:5000/len
>
>
> But when I run it using wsgi server ( gunicorn -b 0.0.0.0:5000 que01:app
> ), I realize it that parts starting from 'if __name__ == '__main__':
> ' is NOT called.
>
> So my question is there any job queueing system that can be embeded into
> existing flask-based restful service ?
>
> Note : in my existing flask script ... most time will not need this queue,
> but some time it'll needed
>
> Sincerely
> -bino-
>
>
>

Re: [flask] embeded queue

From:
bino oetomo
Date:
2014-08-07 @ 10:30
Dear Matt Smith

On Thu, August 7, 2014 5:50 pm, Matt Smith wrote:

> To start the queue you should just move it out of the ifmain.
>
>
>
> *Regards,*
> *Matt Smith*Summoner: *PsyKzz* | *@**PsyKzz*

You RIGHT

I really appreciate your enlightenment

Sincerely
-bino-