Questions tagged [async]
The async tag has no usage guidance.
167
questions
1
vote
0
answers
83
views
How to structure your Python code with asynchronous and synchronous parts
I have a Python FastAPI server application which naturally guides you towards the asynchronous paradigm.
For legacy reasons, I have to support two backends, one which is purely synchronous and one ...
37
votes
7
answers
8k
views
Asynchronous Programming in Functional Languages
I'm mostly a C/C++ programmer, which means that the majority of my experience is with procedural and object-oriented paradigms. However, as many C++ programmers are aware, C++ has shifted in emphasis ...
1
vote
2
answers
1k
views
Multiple API calls potentially spawning multiple Websockets - Threading vs Async
I am designing a program with the flow as outlined below. Note, these are all network calls, there is no system I/O (hard drive).
Initially, multiple independent API calls need to happen - they don'...
2
votes
2
answers
933
views
What are the different messaging patterns for multiple producers to single consumer through a distributed queue?
We have multiple producers that publish messages to the same SQS queue. We have a single consumer that processes the messages. The producers do not care about the response. It is more like a broadcast ...
1
vote
1
answer
84
views
How should I handle routine health checks in a Node.js/Nest.js application?
I have a Nest.js application, and lately I've been thinking about how I can ensure that data is synchronized between two sources - my database and an external database.
For example - and to my ...
1
vote
0
answers
50
views
golang: pattern for handling message queues? Are named functions anti-idiomatic somehow?
Had a discussion today in how to implement services that work with messages coming in from event queues. We call these services processors. One of us argues for using several functions, while the ...
5
votes
1
answer
1k
views
Enforce No Multiple Async Entity Framework Operations
We are working on a large-ish MVC web application with multiple backing stores including a SQL Server database accessed via Entity Framework 6.0. We are using asynchronous operations wherever we can, ...
46
votes
4
answers
12k
views
Who did async/await first?
Python added the async/await constructs in 3.5 in 2015. The Javascript community made steps towards it for a bazzillion years and finally added a very similar implementation to the draft in ES8 ...
0
votes
0
answers
50
views
Single-threaded request-response type server architecture
I'm writing an internet service in Rust that works more or less like an HTTP-server, just without the HTTP part, and strictly over UDP. I also have a requirement to build it like an old-school game of ...
0
votes
0
answers
54
views
React Design - Parent / Child Interaction with Async State
I have a situation involving a parent component, children, and async fetch operations, and I am wondering how to best structure it.
The current code structure I have is as follows:
I have a parent ...
0
votes
0
answers
42
views
Synchranization issue in async jobs created and finished before main thread ends
Main execution thread creates asynchronous job (started and executed by different process) that works on same data that the main thread. For example we create some database entries, that we want to ...
5
votes
1
answer
1k
views
Implementing both Sync and Async clients with DRY
I'm developing a client library. I'd like to provide both Sync and Async interfaces to endpoints on a server. They would be rather easy to implement as completely separate entities, but I would like ...
2
votes
2
answers
328
views
What are the risks in eliminating sync over async?
I'm reviewing changes to a widely used library, which are supposed to be refactorings, and so we want to minimize the risk of introducing any accidental regression. Of course, there are changes from ...
3
votes
1
answer
346
views
Share models between AsyncAPI and RESTful APIs?
What I try to solve:
Given I run a set of microservices, most of which expose a RESTful API and additionally publish or consume events via messaging broker,
and I have decided to go "API first&...
5
votes
1
answer
3k
views
Should web API controller actions that perform no async work always be declared as async?
I have been going over our app web api and making sure all async work is async all the way - and no artificial asynchronicity is enforced.
Say I have the following web api controller:
[HttpGet]
...
0
votes
1
answer
160
views
Bubbling errors upstream in async message-based services
Imagine a simple set up of an API and a 2nd service, where the API pushes some msgs to the message queue and the service pulls them and processes them.
Now, if an error occurs while processing a msg, ...
3
votes
2
answers
981
views
Data Access Layer with Asynchronous services like MQ
I am tasked with creating a development, design and architecture guide for a large multi-year project. I have to dictate best design practices for a number of architectural perspectives. See the ...
0
votes
1
answer
380
views
How to optimize average rating calculation in a review system?
I'm thinking of a designing a review system (restaurant, hotel etc) where users can drop star reviews. Typically in a such a application, you can see the average rating of an entity along with all ...
16
votes
3
answers
11k
views
How will C# 5 async support help UI thread synchronization issues?
I heard somewhere that C# 5 async-await will be so awesome that you will not have to worry about doing this:
if (InvokeRequired)
{
BeginInvoke(...);
return;
}
// do your stuff here
It looks ...
5
votes
4
answers
861
views
Where was "async" all these days? [closed]
It was started with C# 5's new keyword "async". And now I see this async programming everywhere from Javascript to C++, mostly from Microsoft. And from various discussions I came to know, this is a ...
0
votes
1
answer
217
views
Can resource which requires asynchronous cleanup be constructed synchronously?
More specifically this applies only to resources which have asynchronous dependencies themselves (but I think that's majority of them).
Concrete example:
class Foo : IAsyncDisposable
{
public ...
45
votes
6
answers
24k
views
In JavaScript, how is awaiting the result of an async different than sync calls?
I'm having a hard time wrapping my head around the use of async/await and regular sync function calls in JavaScript.
Let's say I have two functions:
Function 1:
async function doSomething() {
...
0
votes
3
answers
182
views
Critical section with two different "rights of way" [closed]
In C#, how do I handle critical section with two different "rights of way"?
Theoretical use case: imagine a swimming pool (the resource). Many individual swimmers (worker threads A, B, C, ...
5
votes
2
answers
3k
views
How do JavaScript engines convert async/await to promises under the hood?
I'm curious how the async/await syntax is converted to Promises. Maybe I'm just not thinking about it properly, but I don't know how this code would be converted to a Promise:
async function myFunc(...
3
votes
1
answer
449
views
Isn't asynchronicity an implementation detail?
Consider a simple — and fake — interface:
interface ISuperGetter { Super Get(); }
An implementation would get some Super from RAM.
One would store what it needs on disk.
Yet another could fetch the ...
0
votes
1
answer
80
views
Long-running jobs in an event-driven environment with constrained max-execution-duration
Hello we have an async event-driven system (kotlin, spring cloud stream, rabbitmq) where there might be an event FooPayloadArrived, published by an ingress rest-controller.
Processing this ...
6
votes
3
answers
4k
views
Why is it necessary for every new api to be async?
I'm expressing my frustration here somewhat, but why do many new libraries only have asynchronous APIs? For example I'm creating a small utility to fetch a web page and parse some data from it. ...
4
votes
1
answer
383
views
Could the async keyword be eliminated in a new programming language?
This post implies that the creators of Rust had to add the "async" keyword to make the async/await functionality backward compatible.
Why do we need the async keyword?
In a new language, ...
0
votes
1
answer
618
views
Asynchronous Server in C++
We are looking to develop an asynchronous server in C++. We are coming from C#, which has built-in support for async-await networking. However, with C++ it appears as if it is basically mandatory to ...
-3
votes
1
answer
174
views
Why isn't JavaScript always async? [duplicate]
In JS, code runs single-threaded, that's why asynchronicity is necessary. I cannot use code like result = someRequest(), instead I need to give it a callback someRequest(resultCallback) or write a ...
0
votes
1
answer
82
views
Organizing Parallel Arrays of Promises / Async tasks
I'm struggling a bit for a preferred way to organize a sequence of asynchronous tasks that can be applied in parallel. Say, you are parsing data from many files. In my case I'm using javascript and ...
4
votes
2
answers
736
views
Async library guidance
I'm creating a library that contains a class that exposes several Async methods:
public class MyClass {
public async Task<Foo> DoFooAsync() { /*...*/ }
public async Task<Bar> ...
2
votes
2
answers
341
views
Should I create two synchronous or a single asynchronous rest APIs?
Here is the situation. System A sends the notification as it completes the work items to System B. System A does not know how many items the project consists of. It's just a pass-through system. ...
1
vote
1
answer
2k
views
Measuring async/await overhead
A while ago I read an article stating that overhead of an async/await call was around 50ms. More recently I read an article that it was around 5ms. I was having a discussion about whether we should ...
1
vote
3
answers
1k
views
Is it bad practice to do additional work in IAsyncEnumerable generator method?
Imagine you have to process each row in a large table.
For every single row you have to download some data from a web service and store it in a different database.
Loading all rows at once into the ...
-3
votes
1
answer
137
views
How does a site API determine the difference between a user and program request in a browser?
So this is in regards to scraping yes; no language in particular. Some sites allow you to see a JSON modal if you pull it directly from a web browser. But, at any notion a program is used, immediately ...
0
votes
2
answers
381
views
Why/When do we need to call an async method from a sync method?
It is my first question here so I hope I'm not doing a mistake. I see a plethora of questions in SO that people ask "how can I call an async method from a sync method?". Given my little ...
1
vote
1
answer
237
views
C# design for handling a high rate of async network operations that complete with a callback (hundreds per second)
I am working with a message broker technology, to which events will be published (following an "event carried state transfer" architecture) for consumption by other applications.
The vendor ...
1
vote
1
answer
316
views
C#: Should I define methods as async?
I have a C# (WPF) application which consumes a particular 3rd party API/tool (let's call this Tool A). My colleagues and I are trying to decouple that from our application, so that it is possible to ...
3
votes
3
answers
1k
views
Issues with an interface treating a synchronous action as async
Let's say I'm trying to write a library that abstracts certain actions. In this example I want to turn a light on or off. There could be hundreds of different kinds of lights that are controlled in ...
0
votes
2
answers
148
views
What is the best practice for incorporating asynchronous code in this case?
Context: I'm building a popup widget. The html and css files are stored in S3. I need to get those files asynchronously and then continue with the rest of the logic.
In the code below, I'm getting ...
-2
votes
1
answer
276
views
Designing a sqlite component in C++
I work on a small component in an embedded device (sensor). This component :
Every 5 seconds, sends requests to other components using sockets
(get health check status, operating status etc) and ...
2
votes
1
answer
2k
views
Why no async functions for Utf8JsonReader and ReadOnlySequence
I have used Utf8Json a lot (it is very good) but have since adapted some lower level code and started using Utf8JsonReader directly.
Looking into the code of the Utf8Json library, I see ...
-2
votes
2
answers
552
views
Async Value Object Creation (DDD)
Suppose that I have a Value Object representing an Image URL of a Cake.
To check that it really is a cake, I make an asynchronous API call to a server that checks whether the image really represents ...
4
votes
3
answers
1k
views
How does an hexagonal architecture help with async/await async-over-sync?
In his book "Concurrency in C# Cookbook", Stephen Cleary writes:
If you can, try to organize your code along modern design guidelines, like Ports and Adapters (Hexagonal Architecture), which ...
4
votes
1
answer
1k
views
Difference Between AsyncResult and Task in c#
So, in C#, I understand the historical difference between the two vaguely; a Task is a newer concept and the highest level concurrency native C# offers.
AsyncResult is a bit more ambiguous. For ...
0
votes
1
answer
2k
views
Unit testing async tcp server
I built an async multi-client TCP server for RPC usage. It's working well but I've found it difficult to unit test certain functionality:
Connect 2x clients, is client count 2
Connect 1x ...
1
vote
1
answer
280
views
How is an async stack implemented?
I am working on creating a simple VM sort of thing in JS:
let sp = 0 // stack pointer
let m = [] // memory
initialize:
sp = 0
invoke:
m[sp] = m[sp - 1] // position in stack
m[sp + 1] = input[m[...
12
votes
1
answer
17k
views
Async Controllers in ASP.NET MVC: Real Advantages / How Achieved?
I have been working through an article about asynchronous controller methods in ASP.NET MVC (http://visualstudiomagazine.com/articles/2013/07/23/async-actions-in-aspnet-mvc-4.aspx) and I think I may ...
0
votes
0
answers
65
views
Streaming Promises in NodeJS
Imagine a typical HTTP service that does async db queries. If HTTP requests are received more quickly than the db can complete queries (such as because the db disk or network is slow), the Promises ...