Coder Social home page Coder Social logo

rent-a-bot's People

Contributors

cpoisson avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

vbarbaresi

rent-a-bot's Issues

lock resource by tag

User story

As an automation client
I want an api to lock a resource knowing it's name or tags
So That I can directly lock the type of resource knowing it's tags, name or id

Acceptance Criterias

One or Multiple resources available

Given one or multiple resources with one or multiple tags
And the resource(s) are available
When requesting a lock using one or multiple tags as criterias
Then A resource is locked and returned within the return informations (resource and lock token)

No resources available

Given one or multiple resources with one or multiple tags
And the resource(s) are not available
When requesting a lock using one or multiple tags as criterias
Then A 403 forbidden resource already locked answer must be returned

No tag(s) match the request

Given one or multiple resources with one or multiple tags
When requesting a lock using one or multiple other tags as criterias
Then A 404 resource not found MUST be returned

Potential race conditions on multi threaded server

I don't see a locking mechanism on database operations.

If I run flask in threaded mode with flask run --with-threads, I can produce race conditions:

  • We enter in lock_by_id() 2 times, and it succeeds to lock both times (to reproduce easily, add a sleep on the db operations in controller lock_resource)
  • The resource has been locked twice and only the second response lock-token is valid.

Suggestion: use threading.lock or sqlite locks to make the app thread-safe

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.