Comments (3)
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:
-
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).
-
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. -
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).
-
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 onreceiveMsg_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.
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.
That's great news, and you're welcome: I'm glad it's useful for you.
from thespian.
Related Issues (20)
- Low performance sending low latency messages between actors
- Is this project still active? HOT 2
- MultiprocTCPBase cannot determine socket address when computer is offline
- Dynamically creating actors HOT 1
- Getting exceptions While Using "multiprocTCPBase" and logdefs in virtualenvironment HOT 7
- Why do I not see a reply message logging for these "Person" actors? HOT 2
- how to run thespian with an event loop HOT 1
- Error using multiprocQueueBase and multiprocTCPBase HOT 3
- Example http_server2.py doesn't work like described HOT 1
- questions: how can I avoid main thread exits when run actors with multiprocQueueBase HOT 9
- Problem with reaching an actor (from the outside) after a while HOT 5
- question: Is there any way to use/integrate external message broker ? (for example rabbitMQ) HOT 2
- self.createActor() with globalName from inisde an ActorTypeDispatcher increases size of self HOT 1
- Assorted Windows Hiccups HOT 1
- TCPTransport: multiple "dictionary changed size during iteration" issues
- multiprocTCPBase: Example keeps breaking on `InvalidActorSpecification` on my machine HOT 4
- Setting TCP_NODELAY on macOS sometimes fails HOT 9
- Dead letter handling with multiprocQueueBase implementation HOT 3
- MultiProcessQueue crashes on KeyboardInterrupt HOT 5
- `logdirector`'s "Dirty Trick" just bit me. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thespian.