Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [async-await]

This covers the asynchronous programming model supported by various programming languages, using the async and await keywords.

2
votes
1answer
35 views

Await socket Response

I wrote this to make the "callback hell" more manageable on the part of the coder when using Socket IO, so that there wasn't really any callback hell to go with, just a simple await. This should work ...
2
votes
0answers
56 views

Sending notifications with Django channels

I have project on Django wich use Django Channels. I use Django Channel for sending notifications to users who are subscribed to articles changes (adding/editing/deleting comments on article). So I'...
2
votes
1answer
31 views

Chart of answered CR posts percentages over time - Part 2

I created a graph to show the change in the percentage of questions answered over time and the first version fetched data from chat transcripts using PHP. The sub-domain I have registered for my ...
0
votes
1answer
43 views

Sleep and prolong sleep

What do you think about such an object function? ...
2
votes
1answer
274 views

Executing query until there is nothing more left

I often query a database to get a batch of items to procees. I do this as long as the query returns some items. I use this pattern quite a lot so I thought I create a small helper so that I don't have ...
0
votes
1answer
87 views

Extension method to to run any async method synchronously

Sometimes I need to call async code from a synchronous method. This leads to repetition in code to wait for the task to complete, then ensure that the expected ...
2
votes
0answers
38 views

Conditional AsyncLock implementation

I have a case where I match data from DB by the various filters. Until the match is updated in the DB, I don't want to accept requests for matching with the same criteria, as this could produce ...
3
votes
2answers
73 views

Streaming modified lines of a file from a Controller

I am writing a piece of software that aims at streaming the modified lines of an external file located at given uri (and retrieved as a QueryString parameter). I am trying to minimize the impact of ...
2
votes
1answer
68 views

Simple but important function to check and retry given action's result

What I'm trying to achieve is Given a predicate function and an action which returns the object to check, check predicate, retry and fail after numTries .. or success . Purpose of this function ...
-1
votes
1answer
41 views

#Error Handling- Propagating errors to calling function.

Im new to javascript programming and i am required to make a web app. Node.js will be used as the js runtime environment. In order to minimize the amount of time needed for debugging as the app ...
4
votes
2answers
61 views

Initializing multiple variables with different types using parallel calls

Consider the pattern below, where multiple async calls are made in parallel: ...
1
vote
0answers
32 views

Async API Function with Mongoose

I'm quite new to the language and I just started using async/await. I've written this function for an API that I'm developing. It checks what is sent by the user, specially the status that he wants to ...
2
votes
1answer
51 views

Javascript class to geocode Dutch addresses

I am relatively new to javascript ES6, the code I've written is working fine. However I am curious if this would be the best approach. I am trying to write a reusable module that I can use in multiple ...
3
votes
1answer
218 views

ForEachAsync extension method (a way to run an async operation on each item of a sequence in parallel)

In a recent project I worked on we faced some issues due to an excess of parallelization (thousands of threads were created and the overall result was a degradation of performance and several spikes ...
1
vote
0answers
84 views

React widget to display, sort and search remote data

I've created a React widget that pulls data on crypto-token pairs from a remote API and makes that data sortable by headers and searchable. You can view a demo of it here. Is this a maintainable way ...
0
votes
1answer
88 views

Asynchronously fetching data from the database

The following C# code is written to fetch the Categories data from SQL Server Database using Asynchronous Task for HttpGet. The Dapper library is used as ORM. I ...
4
votes
0answers
59 views

pool of python coroutines

Task control how much coroutines are running simultaneously with ability to stop the process from inside. Use case when scraping websites you want to control how much memory program consumes and ...
0
votes
0answers
70 views

An `async..await` based way to handle the output of a child process

I've recently answered a question on Stack Overflow where the asker was wondering how to read from the standard out of a child process he was spawning inside a ...
0
votes
0answers
51 views

Await a list of API updates asynchronously

I have an application that fetches a list of products from an API and sends it to another. The second API call is slower than the first so I want it to start before all the items have been fetched. ...
4
votes
1answer
69 views

Async/Await Computation Expression

When writing asynchronous code in F#, one often needs to call methods in the .NET BCL that return Task or Task<T> rather ...
2
votes
0answers
93 views

Server app: pinging up to 500 clients asynchronyosly

TCP/IP server which controls up to 500 clients. There's a list of added computers and the server gets this list, selects computers which are not already connected and ping them using host name. ...
1
vote
2answers
315 views

Starting a process asynchronous

For executing a Process I've created an separate class which binds the possibilities together, for example reading output, start as Admin, catch Exceptions and also start all this asynchronous. Are ...
4
votes
1answer
118 views

CLI to bump package.json version and add git tags

I'm writing a command line app in node.js. At this stage, the app does the following: Get the version from package.json Update the package.json with a new version ...
0
votes
0answers
39 views

Asynchronous API handler function to update a game

I think mainly the GameController can use some optimization Game Entity.ts ...
5
votes
1answer
432 views

Asynchronous dictionary in Python

So I am working on writing a discord bot with discord.py. I decided, rather than making a serie of if/elif, to map the messages to the functions in a dictionnary, like so: ...
7
votes
0answers
64 views

Creating API clients that are “async agnostic”

Python3's async/await syntax is great, but it does create a divide between libraries which are async-based and those which are ...
2
votes
0answers
324 views

Async/await Mysql wrapper

I used MySQL, but it was inconvenient so I made a wrapper. It works, but I'm unsure if there are any issues. Used node module - mysql2, bluebird sqlWarpper.js ...
3
votes
1answer
763 views

Google Drive upload for large files

I'm using Google Drive API for uploading large disk image files ( >100 GB). My Code uses this wrapper to upload these large files in chunks of 40mb. The files are stored on NAS drive. The code works ...
1
vote
1answer
105 views

Return combined DTO from async controller

I have an asynchronous controller. It is supposed to make a couple async calls then return combined data from then as one DTO. ...
3
votes
0answers
42 views

Coordination function

This function started very clean but I had to add requirements: Added a Stopwatch to only update the caller periodically. I guess that responsibility could be ...
3
votes
1answer
1k views

Simple server using async and HttpListener

I have a program that controls a custom machine. I wanted to add some simple HTTP comms so I could control it from the network or other programs. My server class is: ...
-5
votes
1answer
138 views

Optimal way to iterate between await operator calls

Is there any cleaner way to implement the following? ...
0
votes
0answers
66 views

Login function using async/await

I have implemented a login function using async/await. The thing is, I don't think my error handling is as clean as it can be. There are return statements in the middle to stop the execution, which ...
6
votes
2answers
4k views

Task timer async

I had been still using BackGroundWorker and decided to learn async Task. My test project is a simple timer that can be canceled. The target project is to read instruments with a delay for sampling. ...
-2
votes
1answer
30 views

Convert this method into parallel await [closed]

I am using Node.js. I have two different classes. The first one is called Controller, the second is called ServerCommunicator. Controller calls a method in SC (sendDataToDolibarrAsync), which takes a ...
4
votes
2answers
249 views

Asynchronously fetching Bitcoin orders and quotes

I have the following code to get data using async/await ...
5
votes
1answer
927 views

Process List asynchronously with SemaphoreSlim for throttling extension method

I've got some methods that follow a similar pattern, and wanted to abstract some of the logic away into an extension method. Specifically, I am processing lists of objects with the TPL, and throttling ...
1
vote
0answers
69 views

Creating a menu for a quiz

I've built a menu for a quiz, where everything is hard-coded apart from the categories, which I'm pulling from an API using Axios. Api.js ...
5
votes
1answer
93 views

Scheduling using System.IObservable 2.0

As a follow up to this first attempt to create and use my own IObservable<T> implementation, this is version 2.0. The goal has been to correct the code where ...
-1
votes
1answer
405 views

Ado.Net and Async insert of many rows to db

I have implemented repository in Ado.Net which insert data to many tables. I insert all in one transaction and use async/await to improve performances. If you have any suggestions have to improve my ...
4
votes
1answer
78 views

Scheduling using System.IObservable

With great inspiration from t3chb0ts ongoing work about scheduling, cron jobs etc. (last post here), I decided to make my own version of the Scheduler - using the observer pattern - as a learning ...
4
votes
0answers
90 views

Scheduler built with observables v2 (follow-up)

It would probably be too easy if the old Scheduler worked as intended being that simple. But an eye-openig review showed that from time to time it'll miss one ...
3
votes
3answers
351 views

ListBox async filtering, cancelling previous task on filter update

I'm trying to come up with a nice way of filtering a ListBox asynchronously, to keep the UI responsive. The filtering gets fired off asynchronously each time the ...
2
votes
2answers
557 views

Promise.all, but with enforced limit on concurrent promises

I'm trying to implement parallelLimit() to limit the number of parallel tasks that can be performed at any time. Personally, I'm using this function for limiting ...
2
votes
2answers
100 views

Using await to break long-running processes

I have a Node.js app / Web API that runs on an Azure app service with a single CPU. One of the functions needs to run for a long time, perhaps tens of seconds, while the server should continue to ...
1
vote
2answers
161 views

Asynchronous Queue

implemented a basic Asynchronous Queue so, that I can do await queue.push(item); const item = await queue.pop(); basically I'm trying to convert a synchronous ...
1
vote
1answer
43 views

Asynchronous Stack

implemented a basic asynchronous stack so, that I can do. await stack.push(item); const item = await stack.pop(); basically I'm registering listeners when ever i'...
1
vote
0answers
407 views

Semaphore of size 1 [closed]

I was wondering how to implement a simple semaphore of size 1 in javascript. I came up with this and tested it a bit, and wanted to make sure it covers all cases. ...
3
votes
0answers
275 views

Blocking Promise-driven queues with ECMAScript's async/await and generators

I implemented an AsyncQueue, whose dequeue() operation returns a Promise. The ...
1
vote
1answer
1k views

Testing async method call from constructor

I have a project where I want to build a more sophisticated ToDo list - basically a personal project management system. I'm just starting out with the project, and I'd like some feedback on whether my ...