Giter VIP home page Giter VIP logo

demo-fastapi-async-processing's Introduction

FastAPI Task Management

This is a simple app to demonstrate a simple task management API.

Tasks are run using FastAPI Background Tasks as async functions. The "task" is a sleep for 10 seconds.

The following endpoints are provided:

  • /docs - the SwaggerUI for this App. Also usable to try out the service.

  • /start: starts a new task, returns something like:

    {"task_id":"4d15b40a748341358a6024437ef7de4c"}

    The task is started in a Background Task and listens also on a redis queue specific for this task to await potential cancellation.

  • /status/{task_id}: returns the status of the given task which is either unknown, started, finished or cancelled.

  • /cancel/{task_id}: cancel a task when it is started, no-op if status is otherwise. This sends a message via Redis to a task specific queue.

Development

To set up everything:

pip install -r requirements.txt

To start redis:

docker run --name my-redis -p 6379:6379 --rm redis

To start the app:

uvicorn app.main:app --reload

Which now listens on 127.0.0.1:8000

demo-fastapi-async-processing's People

Contributors

constantinius avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

ungarj

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.