librelist archives

« back to archive

Possible to have a thread that always runs inside the flask process?

Possible to have a thread that always runs inside the flask process?

From:
dorian i
Date:
2013-05-04 @ 13:59
Basically i want the thread to have:

while True:
    pass

Re: Possible to have a thread that always runs inside the flask process?

From:
dorian i
Date:
2013-05-04 @ 15:51
Fixed. My problem in the beginning was that i was calling t.run() instead
of t.start()

@application.before_first_request
def start_worker():
    def thread_queue():
        count = 0
        while True:
            count +=1
            time.sleep(1)
            print count
    t = Thread(target=thread_queue)
    t.start()


On Sat, May 4, 2013 at 3:59 PM, dorian i <dorian.hoxha@gmail.com> wrote:

> Basically i want the thread to have:
>
> while True:
>     pass
>