async-await Questions

7

Is there a way to use pool.getConnection() taken from the mysqljs/mysql lib with the async/ await syntax? The idea is to have a method which returns one connection which can be passed around among...
Dunaj asked 5/2, 2018 at 16:11

3

Solved

I am trying to build a wrapper over Notion JS SDK's iteratePaginatedAPI that handles errors as well. I feel particularly lost on how do I catch API errors in such a way that I can actually retry th...
Czernowitz asked 14/2, 2023 at 21:37

2

Solved

The docs for cancel make it sound like you should usually propagate CancelledError exceptions: Therefore, unlike Future.cancel(), Task.cancel() does not guarantee that the Task will be cancelled, ...

5

Let say I have this code class Duck{ func walk() async { //do something print("walk start") try? await Task.sleep(nanoseconds: UInt64(2e9)) print("walk end") } func q...
Choe asked 23/3, 2022 at 11:43

4

Solved

Here is my server mcve: const express = require("express"); const app = express(); const fs = require("fs"); const dbFile = "./sqlite.db"; const exists = fs.existsSyn...
Rollerskate asked 15/10, 2020 at 13:7

2

Solved

I'm building a wrapper for an API. For now, it works. However, it is synchronous, using the requests module for HTTP calls. I would like to implement a way to asynchronously call these methods wh...
Crossfertilization asked 22/9, 2018 at 17:30

4

I am trying to call functions from EventKit in a simple command line tool app. However, some of the functions are async, which results in 'async' call in a function that does not support concurrenc...
Bryanbryana asked 21/8, 2022 at 0:55

3

Solved

What's the best way to add a timeout to an awaiting function? Example: /// lets pretend this is in a library that I'm using and I can't mess with the guts of this thing func fetchSomething() async...
Brood asked 6/12, 2022 at 23:23

4

Solved

I would like to replicate the behavior and ergonomics of taking a closure/function as an argument much like map does: iterator.map(|x| ...). I've noticed that some library code allows passing in a...
Oletta asked 17/3, 2020 at 7:12

4

I'm writing some tests in selenium webdriver js. I start by typing: it('blah blah blah', async () => { await driver }) Then I type . after driver. Suggestions come up. Then I select findElem...
Delmydeloach asked 18/1, 2020 at 18:20

4

Solved

I want to schedule a function which is asynchronous (async/await ruturn type) to run for every two minutes. I tried with generic setInterval, node modules like node-schedule , cron, node-cron, asyn...
Simplicity asked 21/10, 2019 at 11:17

2

Solved

I am writing a class and want to use an async function in the __init__ method to set up some variables needed for the class. The problem is, I can't do that, because __init__ has to be synchronous....
Cholecystitis asked 15/4, 2019 at 19:28

2

Solved

I have a situation like this: var retrievalTasks = new Task[2]; retrievalTasks[0] = GetNodesAsync(); retrievalTasks[1] = GetAssetsToHandleAsync(); Task.WaitAll(retrievalTasks); And I wo...
Bibliolatry asked 11/6, 2018 at 9:55

3

Solved

I use async / await a lot in JavaScript. Now I’m gradually converting some parts of my code bases to TypeScript. In some cases my functions accept a function that will be called and awaited. This ...
Epidemic asked 7/5, 2019 at 11:27

2

Solved

I'm trying to implement my own async method builder for a custom awaitable type. My awaitable type is just a struct containing a ValueTask<T>. The problem is my asynchronous method builder on...
Gain asked 30/9, 2021 at 17:57

8

Solved

As you can see in this code: public async void TaskDelayTest() { while (LoopCheck) { for (int i = 0; i < 100; i++) { textBox1.Text = i.ToString(); await Task.Delay(1000); } } } I want...
Starryeyed asked 4/4, 2014 at 20:38

2

Solved

I've got a caching class that uses cold (unstarted) tasks to avoid running the expensive thing multiple times. public class AsyncConcurrentDictionary<TKey, TValue> : System.Collections.Concu...

5

I've created a login screen where when user press on the login button it calls out an event LoginButtonOnPressedEvent. Below is my onLoginButtonOnPressedEvent function in my LoginBloc class. Futur...
Tomcat asked 9/4, 2022 at 6:5

3

Solved

For simplicity let's imagine we have a method that should return an object while doing some heavy operation. There're two ways to implement: public Task<object> Foo() { return Task.Ru...
Upanishad asked 25/3, 2016 at 7:44

3

Solved

When using IProgress<T> to report progress, should it be the responsibility of the code reporting progress to limit its progress reports to a frequency that is "reasonable", -or- t...
Welker asked 29/10, 2013 at 14:35

2

Solved

I have a C# WPF program that opens a file, reads it line by line, manipulates each line then writes the line out to another file. That part worked fine. I wanted to add some progress reporting so I...
Cavort asked 30/9, 2017 at 1:3

8

Solved

I have lots of async methods in my server code, but I suspect that I have callers without await. Is there a simple way to scan the code for calls where await is missing? public async Task DomeSom...
Buffybuford asked 16/5, 2016 at 13:5

3

Solved

I am trying es6 in js along with async/await. What i have done is : html code <input type="button" onclick="javascript:examplefunction()" /> Js code in seperate example.js file, which i...
Candelabra asked 11/12, 2019 at 12:51

2

Solved

We are using IssuerSigningKeyResolver which is part of Microsoft.IdentityModel.Tokens for our token validation and accepts non async delegate. We call a method which is async and that will result i...
Flowerlike asked 31/3, 2021 at 17:53

3

Solved

When working with synchronous code, I can use panic::catch_unwind like this: #[actix_rt::test] async fn test_sync() -> Result<(), Error> { println!("before catch_unwind"); let ...
Snakeroot asked 29/7, 2020 at 17:40

© 2022 - 2024 — McMap. All rights reserved.