Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8573867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:20:53+00:00 2026-06-11T19:20:53+00:00

I have to do some long work in my Flask app. And I want

  • 0

I have to do some long work in my Flask app. And I want to do it async. Just start working, and then check status from javascript.

I’m trying to do something like:

@app.route('/sync')
def sync():
    p = Process(target=routine, args=('abc',))
    p.start()

    return "Working..."

But this it creates defunct gunicorn workers.

How can it be solved? Should I use something like Celery?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:20:55+00:00Added an answer on June 11, 2026 at 7:20 pm

    There are many options. You can develop your own solution, use Celery or Twisted (I’m sure there are more already-made options out there but those are the most common ones).

    Developing your in-house solution isn’t difficult. You can use the multiprocessing module of the Python standard library:

    • When a task arrives you insert a row in your database with the task id and status.
    • Then launch a process to perform the work which updates the row status at finish.
    • You can have a view to check if the task is finished, which actually just checks the status in the corresponding.

    Of course you have to think where you want to store the result of the computation and what happens with errors.

    Going with Celery is also easy. It would look like the following.
    To define a function to be executed asynchronously:

    @celery.task
    def mytask(data):
    
        ... do a lot of work ...
    

    Then instead of calling the task directly, like mytask(data), which would execute it straight away, use the delay method:

    result = mytask.delay(mydata)
    

    Finally, you can check if the result is available or not with ready:

    result.ready()
    

    However, remember that to use Celery you have to run an external worker process.

    I haven’t ever taken a look to Twisted so I cannot tell you if it more or less complex than this (but it should be fine to do what you want to do too).

    In any case, any of those solutions should work fine with Flask. To check the result it doesn’t matter at all if you use Javascript. Just make the view that checks the status return JSON (you can use Flask’s jsonify).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some rather long string containing just about anything that I want to
I have got Sinatra/Rails app and an action which starts some long process. Ordinary
I'm working with some binary data that I have stored in arbitrarily long arrays
I'm trying to work with some long file paths (Windows) in Python and have
I have some errors from Date and Long types and Overlay Types. Both uses
I'm now doing some work with decoding MP3 files, but just have some basic
In my Universal App I have a long UITableView with custom cells..and for some
In my isometric flash game I have some models with long shadows. I want
I have the following code: @anatomy = Anatomy.find_by_sql( some long sql here) I want
I have some long running scripts with breaks requiring input/interaction to continue but when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.