Giter VIP home page Giter VIP logo

flask-celery-mp-expermients's Introduction

Flask Celery Multiprocessing

A demo app to explore patterns for MP in flask and celery apps.

This will publish a message to a python multiprocessing Queue when a page is loaded or a task is ran.

When the flask/celery app is started it will also start a Process which will read from the queue. Once it has read the batch size (which is set to 3 here) it will print the messages it has received from the queue.

It's the most strpped down version of this pattern. See the sentry_sdk for a more full featured example.

Demonstrating the flask app functionality

You should be able to run gunicorn flask_app:app to start the flask app.

Then, view the demo page at http://127.0.0.1:8000 and after 3 page loads it will print the queue contents:

['Page loaded', 'Page loaded', 'Page loaded']

Demonstrating the celery app functionality

You should be able to run celery -A celery_app worker --loglevel info to start a celery worker process.

Then, running python celery_app.py will dispatch the add task.

After the 3rd execution of a task it will print the queue contents:

['Task run', 'Task run', 'Task run']

flask-celery-mp-expermients's People

Contributors

tomharvey avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.