Skip to main content
Filter by
Sorted by
Tagged with
Advice
1 vote
2 replies
65 views

so I have been diving into NodeJS's internals and specifically in the event loop and how it handles different phases and whilst I was reading and wrapping my head around things I had a thought about ...
Omar Handouk's user avatar
2 votes
1 answer
100 views

Looking at the documentation for Event Loop, there is this example: import asyncio import concurrent.futures def blocking_io(): # File operations (such as logging) can block the # event loop: ...
squinterodlr's user avatar
1 vote
1 answer
94 views

I've returned to a bot I created using the py-cord module several months ago, on a new device where I've reinstalled py-cord. The bot loaded fine when I was originally working on it, but now when I ...
Jasper Osbourne's user avatar
0 votes
0 answers
44 views

I'm using FastAPI inside an Azure Function app with a simple synchronous endpoint doing a query_entities on a TableClient object (the endpoint response is fast). Everything is working but when ...
ruy's user avatar
  • 23
0 votes
1 answer
107 views

I have a simple FastAPI server with just one WebSocket endpoint. It receives a terminal command, executes it locally, and broadcasts the stdout to the client every second: from fastapi import FastAPI, ...
IzaeDA's user avatar
  • 449
2 votes
1 answer
163 views

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 ...
efenatuyo's user avatar
2 votes
1 answer
177 views

I'm running the code below. The output I was expecting was: Start -> End -> While expires -> joke -> setTimeout However, the output I’m actually getting is: Start -> End -> While ...
Interstellar's user avatar
0 votes
1 answer
69 views

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(&...
Himanshu Dudhatra's user avatar
1 vote
0 answers
109 views

This is not a duplicate of another question, as I've searched here and did not find an answer. I'm learning about the Node.js event loop and tried the following code, which behaves differently ...
Eliyahu Machluf's user avatar
2 votes
3 answers
439 views

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 ...
Yamen Alghrer's user avatar
0 votes
1 answer
84 views

I am using FuncAnimation in a Jupyter notebook. Here is the code (in Jupytext's "percent" format, where every # %% indicates a new cell): # --- # jupyter: # jupytext: # formats: ipynb,...
Ziyuan's user avatar
  • 4,620
-1 votes
1 answer
259 views

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 ...
Galina's user avatar
  • 556
1 vote
0 answers
170 views

I'm working on a FastAPI application where I need to initialize an async service by loading some large backing data files asynchronously. However, I'm running into issues when using fastapi dev (...
Ivan Webber's user avatar
0 votes
1 answer
60 views

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 ...
Jan Thomä's user avatar
  • 13.7k
2 votes
1 answer
128 views

In this example: const foo = async () => { const a = await (Promise.resolve(1).then(v => console.log(v))); console.log('foo'); return 1; } const value = foo(); value .then(a => ...
b3rry's user avatar
  • 97
0 votes
3 answers
108 views

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 ...
Artem_3elt3er's user avatar
1 vote
1 answer
142 views

Out of an academic interest I am trying to understand the order of microtasks in case of multiple Promise chains. I. Two Promise chains These execute in a predictable "zipped" way: Promise....
Serge's user avatar
  • 1,613
0 votes
1 answer
39 views

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
Andres Diaz's user avatar
0 votes
1 answer
105 views

When does Promise resolve/reject actually add a micro task? I read the Promise/A+ implementation code from here, and understood that task adding action is triggered after resolve() (the mentioned ...
Zexuan Chen's user avatar
1 vote
2 answers
119 views

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 ...
Anatoliy Gavrilov's user avatar
1 vote
2 answers
157 views

This code, below, executes as a result: script start promise1 promise2 script end promise3 race: A Chrome version 131.0.6778.26, and node environment 22.4 both give the same result Why is it that “‘...
jinmokai's user avatar
1 vote
1 answer
109 views

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 ...
Biel Santo's user avatar
0 votes
0 answers
107 views

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 ...
Krishna Sai Social Secretary's user avatar
3 votes
2 answers
185 views

According to MDN, messages in the JavaScript event loop "run to completion". (https://developer.mozilla.org/docs/Web/JavaScript/Event_loop#run-to-completion) But I have created a case where ...
olfek's user avatar
  • 3,532
-5 votes
2 answers
86 views

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 = ...
Oriol Serrabassa's user avatar
1 vote
0 answers
33 views

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....
daego's user avatar
  • 329
1 vote
2 answers
66 views

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 ...
Jason's user avatar
  • 11
1 vote
2 answers
93 views

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 ...
viktaur's user avatar
  • 49
0 votes
1 answer
155 views

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 = ...
Gabriele's user avatar
1 vote
0 answers
45 views

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 ...
Jiang's user avatar
  • 63
0 votes
3 answers
167 views

Code: setTimeout(() => console.log("1"), 1000) const startTime = Date.now() while (Date.now() - startTime < 5000); setTimeout(() => console.log("2"), 0) setTimeout(() => console.log("...
Vadim Sheremetov's user avatar
3 votes
2 answers
94 views

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(...
Avnish Ranwa's user avatar
1 vote
1 answer
229 views

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/...
OOD Waterball's user avatar
1 vote
0 answers
155 views

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 ...
Mr. Developerdude's user avatar
-1 votes
1 answer
167 views

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(...
putta's user avatar
  • 85
0 votes
1 answer
405 views

Background react 18.3 chrome browser v127 Question import { useEffect, useState } from 'react' function App() { const [state, setState] = useState(0); console.log(1); queueMicrotask(() => {...
Byeongin Yoon's user avatar
-4 votes
1 answer
127 views

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 ...
Brian Phan's user avatar
0 votes
0 answers
49 views

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&...
Rajneesh Mishra's user avatar
4 votes
1 answer
515 views

I have this simple code in NodeJs const { eventLoopUtilization } = require('perf_hooks').performance; const { monitorEventLoopDelay } = require('perf_hooks'); const h = monitorEventLoopDelay({ ...
Taz's user avatar
  • 170
1 vote
1 answer
351 views

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 ...
Henry M's user avatar
  • 115
0 votes
1 answer
219 views

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 ...
mardy's user avatar
  • 218
0 votes
1 answer
106 views

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 = ...
troonie-pham's user avatar
0 votes
1 answer
63 views

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 ...
Mayank's user avatar
  • 11
0 votes
1 answer
41 views

I store an object to Cloud Storage like this: const bucket = getStorage().bucket(); const fileRef = bucket.file("/foo/bar"); const storageWriteStream = fileRef.createWriteStream(); const ...
starleaf1's user avatar
  • 2,938
0 votes
1 answer
504 views

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 ...
Gabriel Vanderklok's user avatar
0 votes
0 answers
50 views

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, ...
roman465's user avatar
  • 199
0 votes
1 answer
137 views

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 = ...
Hossein's user avatar
  • 15
-4 votes
2 answers
200 views

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 ...
Chandni Dalal's user avatar
0 votes
2 answers
119 views

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 ...
MaximPro's user avatar
  • 566
0 votes
1 answer
221 views

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)) ...
uhidga's user avatar
  • 27

1
2 3 4 5
23