Questions tagged [async-await]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
12 views

Callback async function with FastAPI (websockets)

Disclaimer: I am new to python so I aplogize if (some parts of) the question sound(s) stupid. I am trying to make an python API which utilizes Stable Diffusion Pipelines. The process of generating ...
Julian S.'s user avatar
0 votes
2 answers
27 views

Button press-animation lags when pressed

I have a button that invokes an async function that applies a filter to an image. When I press the button, the button press-animation (which is built in) lags, even when the function I'm calling is ...
irrbloss's user avatar
  • 207
1 vote
2 answers
43 views

unit test async/await code fails within the body of test

I am trying to write async/await unit test. I have tried ample of combos to make this test pass, but for some reason when the call happens it steps into the viewModel checkNumber(), executes the first ...
dioufism's user avatar
0 votes
0 answers
22 views

async await in javascript array map [duplicate]

function returnPromise(item) { return new Promise((resolve, reject) => { setTimeout(() => { resolve(item * item) }, 1000) }) } async function main() { ...
gun bos's user avatar
  • 51
0 votes
0 answers
10 views

Node.js - optimal way to handle await inside the stream data listener (mbox email parsing)

I'm trying to write a script that counts emails per sender for my mbox file from the gmail takeout (10GB, 150k emails), but my result (sendersCount) logs as empty. const { MboxStream } = require("...
Melody Nelson's user avatar
0 votes
2 answers
62 views

Why is the code not waiting for the listener to complete?

I am trying to wait for the listener to listen to all messages before moving on to console.log("Done") using await but it is not happening. What am I missing. const f = async (leftPaneRowEle,...
ishandutta2007's user avatar
0 votes
0 answers
24 views

mscorlib.dll throws 'System.NullReferenceException' when using SendAsync() function in ASP.NET 4.7.2

I have a web application (ASP.NET 4.7.2, C#). I am using HttpClient to do a POST request to webservice. When it comes to the point to execute this response = await client.SendAsync(request); it ...
athskar's user avatar
  • 228
0 votes
1 answer
57 views

Swift Actor thread safety with continuations

I am reading about actors and as a teaching example I am rewriting an old piece of code which used delegation to use async await. I am using checked continuations to interface the sync to async. I ...
isenwald2022's user avatar
0 votes
0 answers
39 views

async function in flask allows telegram-bot to get only one file properties

I need telegram-bot to open files from clients. Here is my code: from flask import Flask, request import asyncio import telegram app = Flask(__name__) bot = telegram.Bot(token=TOKEN) # Recieve files ...
Maxim Bratukhin's user avatar
-1 votes
1 answer
61 views

Running many Selenium tasks concurrently and preventing system crashes

I am going to get the population rank of each country from a site by Selenium and HtmlAgilityPack (in C#, .NET 7). This code works well for 10 countries, but when I want to request all the countries, ...
BenyaminDev's user avatar
0 votes
0 answers
19 views

Unstable app work when playing fast on a MIDI keyboard (NAudio)

When I press the keys on the MIDI keyboard very quickly, my application is unstable, silence may occur and all WAV-files will be played at once in a few seconds. It works well if you don't play too ...
olegtutaev's user avatar
0 votes
0 answers
12 views

Chrome extension - Uncaught (in promise) TypeError: console.log is not a function

I am new to Chrome extension and I suspect that my issue relates to a question of context but I can not find the answer... I am doing an Hello world test snippet to try to write to a file and that ...
Claude's user avatar
  • 51
0 votes
1 answer
40 views

Use of swift actor in delegate facade

I was reading through this blog, as I have a similar use-case: https://kelvas09.github.io/blog/posts/closure-delegate-to-async/ I noticed the following snippet: actor BluetoothLEScanWrapper { enum ...
isenwald2022's user avatar
0 votes
1 answer
24 views

Force Angular to wait for my function's response

I am creating a custom pipe and calling the google translation service API inside it. The returned value is the value before translation because the function finished execution after the value was ...
Salma Ahmed's user avatar
0 votes
1 answer
17 views

await inside a forEach block in Node.js 14.x AWS lambda code

I have an AWS Lambda function in Node.js 14.x that is triggered by SQS and the code needs to process the data and re-publish to a mqtt topic. This is the code I have using async(event); import { ...
Gus Sabina's user avatar
0 votes
0 answers
25 views

VS code says answer is not a member of None, inline keyboard doesn't do anything

I tried reloading, trying to not use .message, but this does nothing (aiogram 3.0), it seems like something is bugged. This is the code for inline keyboard: me =InlineKeyboardMarkup(inline_keyboard=[ ...
owh's user avatar
  • 1
0 votes
1 answer
81 views

Running asnyc function synchronously

I'm pretty new to JS. I'm using a third-party library that has an async callback. The problem is that I need to run through the function in its entirety before processing the next callback. I'm using ...
WhatTheWhat's user avatar
0 votes
1 answer
63 views

How to run an async/await task when application will be terminated?

I want to update or end a Live Activity when the application is terminated, but those functions are async, and anything inside Task{ } is not get called in the applicationWillTerminate(_) function. ...
zgjie's user avatar
  • 2,098
0 votes
1 answer
21 views

pinia store from fetched data seems not reactive

I am doing a little exercise with Vue, Pinia and Router and I am facing problems with retreiving data from a simple json-server I'll try to explain myself as shortly as possible: Let's say my store ...
Riccardo De Contardi's user avatar
1 vote
1 answer
28 views

Updating state based on fetches

I'm trying to fetches movies OMDB API data you can see 2 fetches, each fetch give array of 10 objects data only, but the data is being incremented on every search, even though I kept i.e reseting ...
Kondaveti Charan's user avatar
0 votes
1 answer
12 views

Async/Await problem trying to create new instance with axios.create using auth0 token,

Bearer token is not resolving in time: Bearer [object Promise] import axios from 'axios' import { Auth0Client } from "@auth0/auth0-spa-js"; import { auth0Config } from 'src/config'; import {...
dryhurst's user avatar
0 votes
0 answers
45 views

Task modifier in SwiftUI runs every time view appears, which leads to unnecessary API calls [closed]

Problem The .task modifier is an awesome new addition to SwiftUI. However, it looks like it runs the task every time that view appears. Even when navigating back to a screen, it fires off the task ...
Dirty's user avatar
  • 35
0 votes
1 answer
42 views

Vue How to return value from async/await function in a computed

I have a vue js searchbar when i type in the input bar it needs to show results based on the matching characters For getting the data I'm using async await function to wait for the api response but it'...
Sriram Prasanth's user avatar
0 votes
1 answer
24 views

How can I group tasks with asyncio in Python to execute them combined serially and concurrently?

I have the following function: async def pre_processing_list_sic_codes( self, start_date: datetime, final_date: datetime, sic_codes: List[str] ) -> Any: ...
Diego L's user avatar
  • 203
0 votes
0 answers
35 views

Async axios request executing before conditions are met

I have an async function which takes a user object as a parameter, then calls 2 hubspot endpoints using the await keyword. The first is a GET request to return a user object from the hubspot database. ...
o-mac's user avatar
  • 1
0 votes
2 answers
147 views

Why do we need async function

I am wondering why we need async function in c#. I did my research and it looks like an async function is used if one has an IO-bound task that one wants to wait for without blocking. public class ...
Skander's user avatar
  • 67
0 votes
1 answer
35 views

Angular : make OnChange event async

Angular is totally new to me. So in my application there is one onChange event of PrimeNG dropdown. And I want to make it async. Code is given below. .ts file code : onChange(event: any) { const ...
iDipa's user avatar
  • 347
-1 votes
0 answers
34 views

async await NOT continuing after promise resolves ts angular

I'm trying to wait for a user to select an option before continuing on with the function similar to the prompt command. I tried to simplify the issue below. It waits at the await as expected but after ...
Ghostly44's user avatar
0 votes
0 answers
10 views

How to use Awaitility to repeatedly call a condition check with variable execution time?

I would like to use Awaitility to assert that a condition returns true within 30 seconds. However, the condition check itself takes a different amount of time (sometimes instantly, sometimes 5 seconds,...
Desk Reference's user avatar
0 votes
1 answer
68 views

Populate C# dictionary in async via conditional arguments before access from threads reading dictionary contents

I am working on an async application that populates a dictionary with key-value pairs of data from one system and then uses the dictionary to determine if a second system has data that matches. The ...
joeschwa's user avatar
  • 3,083
0 votes
0 answers
57 views

How to write unit test for async function that not return any value in Swift?

I have issue about unit test of Async function, Currently I using MockingBird for checking function in Worker class was called from Interactor class or not. The issue is sometime this unit test is ...
Nawin P.'s user avatar
  • 223
0 votes
0 answers
74 views

Task.WhenAll for grabbing data from a web service

I'm currently re-writing an app to use .NET MAUI (targets Windows and Android). Part of the old version has a download routine which grabs anywhere up to 4Mb of data from a web service. I'm currently ...
Nodoid's user avatar
  • 1,449
0 votes
0 answers
36 views

ThreadPool and Synchronous Execution

I have a .NET Core application that uses a ThreadPool. Each thread in the thread pool executes logic that talks to the database and makes HTTPS calls. The ThreadPool.QueueUserWorkItem(ProcessQueue); ...
Md Monjur Ul Hasan's user avatar
0 votes
2 answers
72 views

Infinity loop with async function [closed]

I need to fetch data from server in infinity loop. This code generates a reursion, is this correct way? My code (code updated): function pause(delay) { return new Promise(r => setTimeout(r, delay)) ...
Bener Beer's user avatar
-1 votes
1 answer
22 views

Boolean always returning true in Async Function [duplicate]

Why is my function always returning true? I expected the program to return true about half of the time and result in the anwering machine call the other half of the time. Also, is there a better way ...
shimmyshimmyya7347's user avatar
0 votes
0 answers
20 views

Async IO Error: SyntaxError: 'await' outside function

Accoding to Async IO python docs -> https://docs.python.org/3/library/asyncio.html, I tried exact same code in wsl ubuntu 20.04, >>> import asyncio >>> await asyncio.sleep(10, ...
Sarvesh Gupta's user avatar
-2 votes
2 answers
51 views

What is the difference between waiting for an api call vs not waiting?

<div onClick={async (e) => { await api_call(); }} /> <div onClick={(e) => { api_call(); }} /> What would be ...
Bear Bile Farming is Torture's user avatar
0 votes
0 answers
12 views

Using String Interpolation and Fetch() to Make a Search Form Communicate with an API [duplicate]

I have an issue with my program where I'm trying to use the github api to get github user information by searching for the users name. Some of the errors I'm getting repeatedly include: Access to ...
Hamza 's user avatar
1 vote
1 answer
51 views

How not to block UI thread in WinForms application when executing synchronous operation

I'm writing very simplistic WinForms app for college teachers. Teacher will be able to send files/folders to student computers (30-35 workstations) over the network to network share. I already have ...
v.doro2's user avatar
  • 15
0 votes
0 answers
84 views

WPF ViewModel AsyncCommand Freeze whole UI

I'm developing a straightforward application that features a single datagrid responsible for loading data through MediatR. To facilitate data refresh functionality upon a button click, I've ...
Rich's user avatar
  • 325
0 votes
1 answer
46 views

How can I properly run asynchronous operations sequentially in kotlin?

I am saving a photo. The user takes a photo or selects a photo from the gallery and a request is sent to the service and saved to the locale. Of course, these are done asynchronously and after the ...
NewPartizal's user avatar
1 vote
0 answers
59 views

Global static var provided by third party not concurrency safe

I have the following code declared at the top of my AppDelegate file, in the global scope. let commandLineArguments = CommandLine.arguments Xcode displays the warning Reference to static property '...
bobby123uk's user avatar
0 votes
1 answer
33 views

Why doesn't useMutation return a promise?

My axios instance that just returns a promise: export const add_order = (data) => instance.post(`/Order/addItem`, { ...data }); My mutation: const { mutate } = useMutation(add_order); So my ...
Nikon George's user avatar
2 votes
1 answer
37 views

C#: How to structure async/await code where many requests are made for the same, slow-to-return data, which satisfies them all

I am rewriting a Windows Forms app that has to make a call to a database server. The call can take up to 30 seconds, so I want to cache the result (it doesn't change). How, multiple events can trigger ...
Ann L.'s user avatar
  • 13.8k
-1 votes
2 answers
43 views

What are cases when thread called await method differs from thread after await?

In CLR via C# there is a statement : "thread completing code going after await method can differ from thread before" That is one of reason why lock with await inside is not allowed . But as ...
Виталий Семененя's user avatar
0 votes
1 answer
20 views

How does tornado deal with concurrency?

The tornado-based web application runs with 4 forking sub-processes as following. async def post_fork_main(): app = tornado.web.Application([(r'/', MyHandler)]) server = tornado.httpserver....
taichi_tiger's user avatar
1 vote
3 answers
46 views

Javascript - How to return a value from a function, where the inside of that function uses a .then() statement

EDIT: You need to have a return statement in front of Promise.all as well as a return inside the .then() as commented by Jaromanda X down below. If you're having the same problem try adding this So in ...
dahallor's user avatar
0 votes
1 answer
31 views

python asyncio `loop.create_task` add task in another thread's loop, the task randomly get stucked

console's output the code: import asyncio import time from threading import Thread import threading loop = asyncio.new_event_loop() def print_ids(s, l): print(f"{threading.current_thread()....
ogios's user avatar
  • 13
0 votes
0 answers
32 views

Managing Asynchronous Tasks in Yew for Real-time Updates with Cancellation

I'm currently working on a web application using the Yew framework, and I'm facing challenges in managing asynchronous tasks for real-time updates. The application involves displaying a dynamic list ...
Isaac Dzikum's user avatar
0 votes
2 answers
45 views

Handling errors in void Dart function marked async

I am designing an API and would like to handle a situation when a user marks a void function async by mistake. The simplified code is listed below: void test(void Function() run) { try { for (...
Dan R's user avatar
  • 95

1
2 3 4 5
533