You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am investigating adding Akka.Net in some limited fashion inside an existing project. Actors would need to interface with existing async code which cannot all be converted to use actors.
I noticed that async continuations are seemingly implemented as actor messages, and per Akka semantics, actor messages can be dropped after e.g. PoisonPill or other termination conditions. This seems extremely problematic to me as code like this:
effectively loses its guarantee of disposing the resource after DoSomeWork completes. I tested this with a try-finally in this gist and indeed the continuation ends up in DeadLetters and remaining work (like disposal) is never executed. The idea was to do some cleanup in PostStop, but the cleanup function is IAsyncDisposable.AsyncDispose, so I wrapped this in ActorTaskScheduler.RunTask as suggested here.
If in the general case (actors terminating for any sort of reason e.g. stopped by another actor, an internal exception, etc.) we cannot rely on await continuations ever executing, I'm afraid this is not going to work for our use case.
Is there some general workaround or technique to ensure work scheduled after tasks complete actually gets to execute in context of ReceiveAsync, ActorTaskScheduler.RunTask etc.?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am investigating adding Akka.Net in some limited fashion inside an existing project. Actors would need to interface with existing async code which cannot all be converted to use actors.
I noticed that async continuations are seemingly implemented as actor messages, and per Akka semantics, actor messages can be dropped after e.g. PoisonPill or other termination conditions. This seems extremely problematic to me as code like this:
effectively loses its guarantee of disposing the resource after
DoSomeWork
completes. I tested this with a try-finally in this gist and indeed the continuation ends up in DeadLetters and remaining work (like disposal) is never executed. The idea was to do some cleanup inPostStop
, but the cleanup function isIAsyncDisposable.AsyncDispose
, so I wrapped this inActorTaskScheduler.RunTask
as suggested here.If in the general case (actors terminating for any sort of reason e.g. stopped by another actor, an internal exception, etc.) we cannot rely on await continuations ever executing, I'm afraid this is not going to work for our use case.
Is there some general workaround or technique to ensure work scheduled after tasks complete actually gets to execute in context of
ReceiveAsync
,ActorTaskScheduler.RunTask
etc.?(I've also asked this on Stackoverflow).
Beta Was this translation helpful? Give feedback.
All reactions