1,143 questions
2
votes
1
answer
55
views
Long running asyncio tasks freeze after ~1 hour. How can I debug?
I have a long running Python application built on asyncio. It launches several background tasks that run indefinitely and occasionally performs CPU work using asyncio.to_thread. Everything works fine ...
0
votes
1
answer
66
views
What happens if setTimeout and fs.readFile callbacks are ready at the same time in Node.js?
I'm trying to deeply understand how the Node.js event loop works, especially when its says it sits idle before poll phase.
const fs = require("fs");
setTimeout(() => {
console.log(&...
2
votes
3
answers
230
views
How do I create thread-safe asyncio background tasks?
I have an event loop running in a separate thread from the main thread, and I would like to add a background task to this event loop from the main thread using the asyncio.create_task function.
I am ...
-1
votes
1
answer
153
views
nodejs event loop lag 300ms and huge request latency [closed]
I have a next.js website that under the load 80 requests per seconds (for one pod) shows huge latency 20-30 seconds to handle a simple request like API call.
I checked event loop lag and under the ...
0
votes
1
answer
55
views
Quarkus: How to run long-ish IO tasks during the SSL-handshake without blocking the event loop?
We have a non-negotiable (compliance) requirement to verify a client certificate against a third-party REST service during SSL handshake for our Quarkus-based webservice. We implemented this using a ...
0
votes
3
answers
106
views
Different order for timers when spliting in 2 calls or in a single
In the below code I run 2 sets of tests where a timer is either split in 2 nested calls to setTimeout() and a single call with the timeout set to the sum of both previous calls.
However, I notice that ...
0
votes
1
answer
34
views
Why does NodeJs run twice uv_run()?
Why does NodeJs call the Event Loop method uv_run() twice when I executed the command:
node file.js
// file.js
setTimeout(() => {
console.log('1');
}, 0);
output
1
1
vote
2
answers
107
views
What queues actually exist in the event loop
Most sources say that there are two queues in the Event Loop: microtask queue and macrotask queue. But also some sources highlight the third queue (callbacks generated by requestAnimationFrame) and ...
1
vote
1
answer
93
views
Why is the worker's onmessage executing after a macro task?
Event loop execution order
I'm studying how the Javascript event loop works for a future presentation, but I've come across an unexpected behavior with the information I have so far. Simply put, when ...
0
votes
0
answers
84
views
Event loop in Node JS for Promises
I was going through the event loop in JavaScript and how it makes the JS to perform asynchronous operations even though it is a single threaded language. In that I learnt that the microtasks or ...
-5
votes
2
answers
82
views
How is the promise settled by the time it is logged?
I have the following code:
async function get_exam_score() {
const exam_score = Math.random() * 10;
if (exam_score < 5) {
throw("You failed");
}
}
const promise = ...
1
vote
0
answers
27
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....
0
votes
0
answers
38
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
1
answer
132
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 = ...
0
votes
3
answers
148
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("...
1
vote
1
answer
186
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
votes
1
answer
146
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(...
-4
votes
1
answer
115
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 ...
3
votes
0
answers
460
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
1
answer
184
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
57
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
401
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
1
answer
124
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 = ...
0
votes
2
answers
101
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 ...
2
votes
3
answers
199
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 ...