-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposed fix for #886 asp.net deadlock #905
Conversation
5ab61d3
to
e143615
Compare
Looks good to me, anyone verified if this solves the asp.net deadlocks? |
At least this code is working now |
There are more things happenning here.
|
{
public ActionResult Index()
{
var actor = MvcApplication.ActorSystem.ActorSelection("/user/test");
var res = actor.Ask<string>("ping").Result;
return new ContentResult() {Content = res};
}
} public class MvcApplication : System.Web.HttpApplication
{
public class MyActor : UntypedActor
{
public MyActor()
{
}
protected override void OnReceive(object message)
{
Sender.Tell(message + "-pong");
}
}
public static ActorSystem ActorSystem = ActorSystem.Create("sandbox");
protected void Application_Start()
{
ThreadPool.QueueUserWorkItem(_ => MvcApplication.ActorSystem.ActorOf(Props.Create<MyActor>(), "test"));
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
} Works in this scenario |
You can't do that. You have to move the cast to |
Talking different things here. What I mean is: public static Task<object> Ask(this ICanTell self, object message, TimeSpan? timeout = null)
{
return self.Ask<object>(message, timeout);
}
public static async Task<T> Ask<T>(this ICanTell self, object message, TimeSpan? timeout = null)
{
IActorRefProvider provider = ResolveProvider(self);
if (provider == null)
throw new NotSupportedException("Unable to resolve the target Provider");
ResolveReplyTo();
var result = (T)await Ask(self, message, provider, timeout);
return result;
} First should read as: public static Task<object> Ask(this ICanTell self, object message, TimeSpan? timeout = null)
{
IActorRefProvider provider = ResolveProvider(self);
if (provider == null)
throw new NotSupportedException("Unable to resolve the target Provider");
ResolveReplyTo();
return Ask(self, message, provider, timeout);
}
public static async Task<T> Ask<T>(this ICanTell self, object message, TimeSpan? timeout = null)
{
return (T) await Ask(self, message, timeout);
} The internal Ask already returns a Then you can optimize the await with some ContinueWith logic to execute in the same thread that just casts the value, but that is much more simple than that. With code in the right order, you could just avoid the entire casting logic inside var result = (string) actor.Ask("ping").Result; That's what I mean. |
@kekekeks could you please run the test suite with the debugger attached and see what it's failing on Akka.Tests? Normally when this issue comes up it's a |
Should work now |
Proposed fix for #886 asp.net deadlock
Im pulling this in, tests are passing and the code is cleaner than we have atm. |
See #886