Posts

Showing posts with the label task

async Task() not returning straight away when not using await

Image
Clash Royale CLAN TAG #URR8PPP async Task<T>() not returning straight away when not using await If I have the following function public async Task<bool> Foo() { // call many async functions await Bar1().ConfigureAwait(false); await Bar2().ConfigureAwait(false); return await Bar3().ConfigureAwait(false); } If I call the function above var t1 = Foo(); var t2 = Foo(); ... await Task.WhenAll(t1, t2).ConfigureAwait(false); t2 will not execute until t1 completes, (so calling WaitAll is a bit pointless). WaitAll But if I call ... var t1 = Task.Run( async () => await Foo().ConfigureAwait(false)); var t2 = Task.Run( async () => await Foo().ConfigureAwait(false)); ... await Task.WhenAll(t1, t2).ConfigureAwait(false); t1 and t2 return immediately... And now if I run ... ... var t1 = Task.Run( () => Foo()); var t2 = Task.Run( () => Foo()); ... await Task.WhenAll(t1, t2).ConfigureAwait(false); t1 and t2 also return immediately... Why does Foo() not return task immed...

Django where is celery task information saved?

Image
Clash Royale CLAN TAG #URR8PPP Django where is celery task information saved? I am wondering where the celery task info. is saved. I checked the tables in the database and find no relevant items. It seems when I shut down the local server and restart it later, celery knows the tasks which are in the queue. 1 Answer 1 In celery, we're using Brokers to store task information. Brokers are kind of database , used with celery because they are fast and efficient for a Producer-Consumer scenario Why Not using SQL DB? SQL databases are capable of running in a network and dealing with concurrent access. The problem with them is that they are too slow. NoSQL databases, by contrast, are quite fast, but many times they lack reliability I found one article, Celery: an overview of the architecture and how it works on the internet, which explian everything in simple words Brokers ...