1,132 questions
1
vote
0
answers
17
views
Why puppeteer blocks callbacks from execution?
This code as it is opens the browser and read a txt file line by line:
line 1
line 2
line 3
Stream closed
The thing I don't understand is why placing const browser = await puppeteer....
1
vote
2
answers
47
views
Why does this Node.js script produce different output each time? [duplicate]
This script is from a Nodejs introducing book. This part is about the event loop of Javascript.
const sleep_st = (t) => new Promise((r) => setTimeout(r, t));
const sleep_im = () => new ...
0
votes
0
answers
21
views
Share default webflux EventLoopGroup
I use Spring Webflux in my project. Also there is a Lettuce and grpc library, both use Netty.How can I get default EventLoopGroup from webflux and use it for Lettuce and grpc too?
0
votes
2
answers
48
views
How does the event loop handle timing in a single-core CPU with multiple processes
There are many ways I can think of asking this question. Let's say we have a single-core CPU on which the OS is running two processes. Process 1 is a Node application and process 2, we don't care ...
0
votes
1
answer
51
views
ERROR: Event loop is closed in ThreadPoolExecutor
In a .py module I created this function
from utils.telegram_utils import telegram_message
...
counter = count(1)
def open_websites_with_progress(url):
risultato = ...
1
vote
0
answers
38
views
Can Flutter support "capture" and "bubble" phases for keyboard events like in JavaScript?
In GUI development, there are typically two different behaviors for handling global shortcut keys:
High-priority global shortcuts: These shortcuts take precedence over all other input. If a global ...
0
votes
3
answers
126
views
Why setTimeout is executing this way
Code:
setTimeout(() => console.log("1"), 1000)
const startTime = Date.now()
while (Date.now() - startTime < 5000);
setTimeout(() => console.log("2"), 0)
setTimeout(() => console.log("...
3
votes
2
answers
56
views
Behaviour of setInterval with respect to Event loop
Trying to figure out why the output of the following code is the way it is
console.log("Start");
setInterval(function() {
console.log("setInterval");
}, 5000);
let date = new Date();
while(...
1
vote
1
answer
71
views
Python Asyncio source code analysis: Why does `_get_running_loop` in Python execute the C implementation instead of the Python one?
I've been exploring the async source code and noticed that the function _get_running_loop() is defined both in Python and has a note stating it's implemented in C (in _asynciomodule.c).
# python3.11/...
1
vote
0
answers
99
views
How to fork Qt6 program
I have already exhaustively googled this topic, and the answer is "don't do it".
However I am kind of stuck between a rock and a hard place, so I need to thoroughly explore this topic before ...
-1
votes
1
answer
70
views
Event loop is closed- pytest- FastAPI
In my fastapi application i have written test cases using pytest.
My tests folder includes
conftest.py
import pytest
from fastapi.testclient import TestClient
from main import app
@pytest.fixture(...
0
votes
0
answers
25
views
why setTimeout executed first then the setImmediate in nodeJS-v20.11.0 [duplicate]
console.log("---------Event Order---------");
const fs = require('fs');
const path = require('path');
const currentDir=__dirname
const fileName='example.txt'
const filePath=path.join(...
0
votes
1
answer
70
views
Priority of react's useEffect in Event-Loop
Background
react 18.3
chrome browser v127
Question
import { useEffect, useState } from 'react'
function App() {
const [state, setState] = useState(0);
console.log(1);
queueMicrotask(() => ...
0
votes
0
answers
45
views
Event loop of node.js produces unpredictable results
While exploring the node.js event loop, I realized that poll events appear in some random order, rather than following the order described in the event loop.
The logic of the code is trivial: we ...
-5
votes
1
answer
82
views
Node/ExpressJs fail to handle 1000 requests at the same time
I have 2 expressjs servers:
Server A:
const express = require('express')
const axios = require('axios');
const app = express()
const port = 3000
function deepSleep (duration) {
const start = new ...
0
votes
0
answers
41
views
useEffect and promise priority in inital and subsequent renders
I have below code and help me to find the output with accurate explanation.
'infiniteLoopProtection:false'
import * as React from "react";
import { useState, useEffect } from "react&...
0
votes
0
answers
38
views
Why does a blocked Electron main process block the renderer process, even without IPC?
Based on the Electron process model, I expected that a blocked main process would not cause unresponsiveness in a renderer process, unless that renderer process is somehow waiting on the main process.
...
2
votes
0
answers
313
views
Event loop delay
I have this simple code in NodeJs
const { eventLoopUtilization } = require('perf_hooks').performance;
const { monitorEventLoopDelay } = require('perf_hooks');
const h = monitorEventLoopDelay({ ...
0
votes
0
answers
142
views
How do debug and monitor blocked event loop in Node JS
I am using Express, Node 18, and JS for my back end. Also doing clustering using pm2.
Weirdly enough, I can see that some of my APIs get very slow randomly. CPU and Memory remain fine (I know because ...
0
votes
0
answers
57
views
qasync with IPython hangs on run_until_complete
I would like to have an asynchronous gui with PyQt5. The synchronous version of what I want would look like this:
from PyQt5.QtWidgets import QPushButton, QMainWindow
import asyncio
import time
import ...
1
vote
1
answer
130
views
When using AsyncClients in Google Cloud Python SDK, got future attached to a different loop
I'm quite new to using asyncio in Python. Originally I have a sync function speak:
from google.cloud import texttospeech
client = texttospeech.TextToSpeechClient()
def speak(*args):
# omitted
...
0
votes
0
answers
39
views
Get "RuntimeError: Event loop is closed" while running pytest in django channels
I wrote a test for my websocket connection.
Here is my pytest code.
import pytest
from channels.testing import WebsocketCommunicator
from django.contrib.auth import get_user_model
from ...
0
votes
1
answer
66
views
Integrating sdbus-cpp with the GLib event loop
I need to integrate some code written using sdbus-cpp with my application's event loop, which is the GLib's GMainLoop.
sdbus-cpp's IConnection interface declares the getEventLoopPollData() function ...
0
votes
1
answer
54
views
Vertx single thread become slower when client call many concurrently of APIs to vertx service
I expect your ideas so much for my situation.
I built a RestfulAPI using vertx 4.5.7, vertx-pg-client same version.
When starting I configured pool like this:
final PgConnectOptions connectOptions = ...
0
votes
1
answer
50
views
callback queue , call stack and registered event like setTimeout
what happens if any event is register (like setTimeout) but it takes more time (assume 5,6 min ), and currently call stack and callback queue is completed all task and it is empty, so the program is ...
0
votes
1
answer
31
views
How to make Firebase Cloud Function wait for a stream to close before terminating
I store an object to Cloud Storage like this:
const bucket = getStorage().bucket();
const fileRef = bucket.file("/foo/bar");
const storageWriteStream = fileRef.createWriteStream();
const ...
0
votes
1
answer
142
views
How to properly close a WebSocket connection after running an asynchronous function in Python?
I am running into this problem where the websocket will not close after I run an asynchronous function that asks for input ( i think its interrupting the main event loop or something).This code is ...
0
votes
0
answers
36
views
Why aren't nested `setImmediate` callbacks executed on the same tick of event loop?
According to the node.js docs about event loop:
Each phase has a FIFO queue of callbacks to execute. While each phase is special in its own way, generally, when the event loop enters a given phase, ...
0
votes
1
answer
79
views
Add index to AsyncIOMotorClient while having Async tests
I have a mongo class for my fastAPI application:
`
from motor.motor_asyncio import AsyncIOMotorClient
from config import settings
import asyncio
class Mongo:
def __init__(self):
client = ...
-4
votes
2
answers
107
views
Async operation like fetch, async/await are executed after syncronous code is executed then why microtask queue is given more priority?
micro task Queue consist of callbacks/resolved functions from fetch, async/await. but why its given more priority then callback queue because sync code is executed first and then afterward async ...
0
votes
2
answers
90
views
requestAnimationFrame and its lifecycle
I realized that I was confused with requestAnimationFrame, although some time ago I thought I understood how it works.
So what is the essence of my problem:
They say that requestAnimationFrame, namely ...
0
votes
1
answer
132
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
156
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 ...
0
votes
1
answer
102
views
Confused about how event loop fetch tasks from task queue
Recently I saw the event loop session shared by Jake Archibald. As he mentioned in the time 27:55 of the video, it seems the event loop get task from queue one item per round
However, we I read the ...
0
votes
0
answers
25
views
Difference in the event loop execution for es6 and common js modules [duplicate]
Why is it that the below code gives output differently for es6 modules and common js modules:
process.nextTick(() => console.log("nextTick 1"));
process.nextTick(() => {
console....
2
votes
3
answers
231
views
Node.js - setTimeout - order of execution
In this code:
setTimeout(() => console.log('C'), 100);
setTimeout(() => console.log('D'), 0);
const t1 = new Date();
while (new Date() - t1 < 500) {/* block for 500ms */}
This will log D -&...
4
votes
1
answer
125
views
How to asynchronously run Matplolib server-side with a timeout? The process hangs randomly
I'm trying to reproduce the ChatGPT code interpreter feature where a LLM create figures on demand by executing to code.
Unfortunately Matplotlib hangs 20% of time, I have not managed to understand why....
1
vote
1
answer
79
views
Turtle-based Python game behaves unexpectedly when it is replayed for the second time
I have created a game using Python's turtle package where you use the Up arrow key to help the turtle cross the screen and avoid obstacles while doing so. It has a Replay button that you can click ...
1
vote
1
answer
155
views
Are async, await a replacement for process.nexttick()?
https://nodejs.org/en/learn/asynchronous-work/event-loop-timers-and-nexttick#why-use-processnexttick
I read about process.nexttick() in the official Nodejs documentation above. According to the ...
0
votes
1
answer
555
views
Why does asyncio.run() or loop.run_until_complete() run task that is created but not awaited?
Here is the code.
import asyncio
async def run_test():
print("run1")
await asyncio.sleep(1)
print("run2")
async def main():
print("main1")
loop = ...
0
votes
0
answers
150
views
How to prioritize the tasks of asyncio eventloop?
I want to create a custom implementation of the asyncio eventloop so that the tasks handled by the eventloop have a priority. The tasks that are available or "ready" can then be ordered by ...
-1
votes
1
answer
482
views
Even loop creation in Asyncio of Python
In asyncio library of Python, which method(s) create the event loop? Is it asyncio.run() / asyncio.get_event_loop() ? Also which method(s) start running the event loop? I tried searching; but it seems ...
1
vote
0
answers
113
views
How to use Revolt\EventLoop?
How to run below script using Revolt\EventLoop
use Amp\Loop;
Loop::Run(static function() {
echo "Callback function executed!" . PHP_EOL;
})
Im tried this code but it return blank ...
1
vote
3
answers
129
views
Unexpected behaviour in Python event loop
I have the following piece of Async code in Python.
import asyncio
async def get_some_values_from_io():
print("Getsome value Executing...")
await asyncio.sleep(3)
return [100,...
2
votes
2
answers
208
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
1
answer
134
views
Why does an asynchronous FastAPI have synchronous code in authorization? [duplicate]
Hellow everbody)
Why does authorization have a synchronous library for creating and checking passwords?
Here's the code from the documentation:
def verify_password(plain_password, hashed_password):
...
0
votes
1
answer
39
views
Why 3 setTimeout funcs were executed at the same time (as macrotasks)?
setTimeout is a macrotask right? And event loop executes only 1 macrotask in 1 "tick", as far as I understand. So, why does it look like these functions were executed in one "tick" ...
0
votes
0
answers
138
views
Monitoring asyncio ready queue in python
I'm optimizing the performance of a Python application that includes many non-blocking I/O operations, some of which involve making HTTP API calls. We use an asynchronous client for all I/O operations,...
1
vote
0
answers
121
views
which executes first, nextTick or promises? [duplicate]
i'm trying to understand the output of a test that i've been running because it seems to go against everything that i'm reading and hearing about how the node.js event loop works. supposedly all ...
2
votes
2
answers
247
views
Do callbacks from I/O operations that return promises go to the I/O queue or the microtask queue in Node?
I'm just learning the details of how the event loop in Node works.
I learned that the promise queue takes priority over the timer queue, which takes priority over the I/O queue.
async function ...