All Questions
Tagged with event-loop async-await
54
questions
0
votes
1
answer
98
views
Async/await promises alternative. Rewrite await to Promise
I was trying to understand how await works in different scenarious, and camse across a problem.
new Promise(async (resolve, reject) => {
resolve();
console.log(await Promise.resolve(7))
...
2
votes
3
answers
131
views
Fluent pattern with async methods
This class has async and sync methods (i.e. isHuman):
class Character:
def isHuman(self) -> Self:
if self.human:
return self
raise Exception(f'{self.name} is not human')
async ...
2
votes
2
answers
163
views
How does event loop handles async await internally?
Let us say we have the following async function -
async function foo(x,y) {
x = x+1
await fetch('some_url')
y = y+1
}
When the function foo encounters await, the execution of foo must be ...
0
votes
0
answers
38
views
In Python async function, how to calculate time consumed by overlapped blocking operation and non-blocking operation?
I'm working with an asynchronous Python program that schedules three coroutines. Each coroutine involves:
A blocking operation that takes X seconds (denoted as X_i for the i-th coroutine).
A non-...
0
votes
1
answer
129
views
Is it possible to check if an asyncio.Task is blocked vs ready?
I'm working on a make-like system written in Python and I want to be able to throttle how many cores are in use for parallel building, similar to the -j/--jobs option supported by GNU make. Each build ...
0
votes
2
answers
103
views
Facing difficulty in understanding async await
I'm a beginner. Got confused about async programming after seeing the output of this code
async function f1() {
console.log('this is f1');
let res = await f3();
console.log('result of f1 from ...
1
vote
0
answers
55
views
How does NodeJs handle while(true) using event loop [duplicate]
We are using NodeJs for a highly performant backend system and need to know most of the intricacies around JavaScript and how the NodeJs event loop works. One of our dependencies is the JavaScript ...
1
vote
2
answers
763
views
Understanding JS event loop and render cycles in browser
After watching these talks on the JS event loop and rendering in browsers (What the heck is the event loop anyway? and Web browser event loop, setTimeout, micro tasks, requestAnimationFrame...), I was ...
0
votes
1
answer
212
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()....
0
votes
0
answers
40
views
Async function running before completion of rest of code [duplicate]
Below is the node.jscode to read content of a file
let { readFile, WriteFile } = require('fs')
let create = (path) => {
console.log("Inside function")
return new Promise((resole, ...
1
vote
1
answer
539
views
Doesn't asyncio.run() use the running event_loop if it exists? (asyncio.Queue with producer consumer)
I'm trying to use a asyncio.Queue to implement a producer - consumer pattern.
But I found out that
if i create a Queue out side asyncio.run()
and i set the maxsize of the queue larger than amount of ...
-2
votes
1
answer
59
views
JavaScript web server: Understanding blocking behavior during request handling
I have a web server that needs to fetch and cache around 1000 items that come from a slow api.
I would like the first request and any that hit a ttl expiration to kick off this operation, but then ...
0
votes
1
answer
198
views
Await fetch affects the event loop until I comment it
I am currently studying the event loop that handles NodeJS synchronous and asynchronous functions. From what I understand, synchronous functions will be executed first, then the asynchronous functions....
2
votes
1
answer
208
views
Order of execution for asynchronous tasks in JavaScript: Promise and setTimeout [duplicate]
function job(){
sequenceB()
sequenceC()
}
function sequenceB(){
setTimeout(_ => console.log(`🍅 Timeout at B`), 0);
Promise.resolve().then(_ => console.log('🍍 Promise at B'));
}...
2
votes
1
answer
133
views
Does a returning a Promise from a recursive async function cause a stack/heap overflow?
Given the following piece of code
async function recurse() {
await someAsyncStuff();
return recurse();
}
await recurse(0);
It would make sense that recurse(i) would resolve into recurse(i+1) ...