Giter Site home page Giter Site logo

Comments (3)

kquick avatar kquick commented on August 25, 2024

Hi @kevincolyar,

There is no guarantee of message delivery order in Thespian. Most of the time they will be delivered in the order sent, but there are cases where message arrival doesn't match the send order.

There should be affect on the message ordering when using the ActorTypeDispatcher.

There are a couple of different approaches I would recommend for this situation:

  1. If the CalculationActor knows how many messages are going to be sent to the SaveActor, use a separate message to communicate this information to the SaveActor. The SaveActor can then know when all the work is completed and notify the CalculationActor, at which time the shutdown can be performed. This could also be combined with assigning each CalculationActor result an ID number that the SaveActor can use to confirm receipt and possibly order (if order is important).

  2. An easy alternative is to use a @transient_idle decorator with the SaveActor (http://thespianpy.com/doc/using.html#hH-99783a4a-183f-4b69-8910-014d01edbf1c). The shutdown will be delayed by the idle period, but if the Calculation Actor normally generates output in rapid succession, the delay could be fairly small. The CalculationActor can use the ChildActorExited that it will receive when the transient SaveActor exits to know when to exit itself.

  3. The SaveActor can send back a response for each message it has received. This doubles the number of messages exchanged between the actors, but if the SaveActor storage operation is the bottleneck this increased message count may not be a significant factor. This would allow the CalculationActor to know if and when each result has been saved (and ultimately, when to shutdown).

  4. You could potentially increase the performance of the SaveActor by batching saves to the database. For example, save CalculationActor results in a local Python array, use a self.wakeupAfter(timedelta(milliseconds=600)) and on receiveMsg_WakeupMessage(self, msg, sender) it could save the entire array. You would still need a completion indication as described above, but this could potentially help the SaveActor keep up with the output of the CalculationActor.

I'd be happy to describe any of the above in further detail if you'd like. Also, I apologize for not responding earlier: using the issue tracker at https://github.com/kquick/Thespian may be a little faster for responses.

from thespian.

kevincolyar avatar kevincolyar commented on August 25, 2024

Thanks for your detailed answers, Kevin. I was actually able to convert my SaveCalculation actor to a troupe which can now keep up with the CaclulcationActor. Works great!

Thanks again for Thespian!

from thespian.

kquick avatar kquick commented on August 25, 2024

That's great news, and you're welcome: I'm glad it's useful for you.

from thespian.

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.