Coder Social home page Coder Social logo

srkds / backgroundjob-multiprocessing-flask Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 79 KB

🚀[ Asynchronous operation API ] Let the server handle the requests and send responses back to the 🙋‍♂️clients, meanwhile, the 🕹CPU intensive jobs run in the background on a specific 🛰CPU(CPU affinity)

Home Page: https://youtu.be/9dvaDg0BhSE

Python 100.00%
aws-s3 boto3 flask-api multiprocessing pyppeteer2 python3 api cpu-affinity asynchronous-operation

backgroundjob-multiprocessing-flask's Introduction

Introduction

This project is about background job multiprocessing. Tasks

  • Generate Pdf using multiprocessing in background
  • Set multiprocessing process a cpu affinity
  • Upload generated pdf to AWS S3 bucket
  • Route to get a status of background task

Idea

Ideal case without this implementation

The client sends a request for performing heavy jobs something as generating pdf, or any other time and resource taking jobs. the server will receive this request and start performing the task and the client has to wait for a response then after client can do other things like moving around.

With implementation

The client sends a request for performing a heavy job, and the server will receive this request and process it in the background, meanwhile server will send a response back saying that your job is received with a status URL for getting the status of the background task. In this case, the client need not wait till the heavy job completes its task. Also, the server can take requests meanwhile the heavy job is being done in the background instead of blocking the server from taking requests.

Install

Run following command

python3 my_api.py

send post request to http://127.0.0.1:6060/api/generate/pdf with following body

{
    "html_url":"none",
    "operator": 34
}

send GET request to http://127.0.0.1:6060/api/jobstatus for getting status of background task

backgroundjob-multiprocessing-flask's People

Contributors

srkds avatar

Watchers

 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.