GithubHelp home page GithubHelp logo

Concurrency protection about hdt-node HOT 4 CLOSED

mielvds avatar mielvds commented on May 18, 2024
Concurrency protection

from hdt-node.

Comments (4)

RubenVerborgh avatar RubenVerborgh commented on May 18, 2024

this can more or less only be throttled using await.

But that is exactly what the calling code should do, and it solves the issue, no?

Do you have an example of code that could cause issues?

from hdt-node.

mielvds avatar mielvds commented on May 18, 2024

This is issue is mostly for documentation so I don't forget. There is no imporant use case, no urgent solution necessary.

Possible problematic code could be this (not the best example):

var doc;
hdt.fromFile('./test/test.hdt')
  .then(function(hdtDocument) {
    doc = hdtDocument;

    for (predicate in predicates) {
    doc.searchTriples(null, predicate, null, { offset: 0, limit: 10 }).then(...);
    }
  });

From the calling code, it's not always easy to predict when you are going to run into trouble (you don't know how many results there are and even if you do, you don't know what will be a problem). The library could improve the dev experience by adding some throttling or at least rejecting too many calls.

from hdt-node.

RubenVerborgh avatar RubenVerborgh commented on May 18, 2024

I would argue the above is an issue in the calling code. A for loop is not an adequate solution in presence of asynchronous calls. You have to either code this with a callback function, or more easily with for await.

Native Node.js APIs, such as fs, will also not contain protections against this and similarly rely on the caller to do the right thing.

As such, I don't think that protections belong in the HDT module.

from hdt-node.

mielvds avatar mielvds commented on May 18, 2024

fair enough :)

from hdt-node.

Related Issues (20)

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.