event-loop

NodeJS Event Loop Fundamendals

两盒软妹~` 提交于 2020-01-01 19:13:12
问题 I'm sure it's a commonly asked question but didn't find a concrete answer. I kind of understand the basic concept of NodeJS and it's asynchronous/non-blocking nature of processing I/O. For argument sake, let's take a simple example of a HTTP server written in node that executes the unix command 'find /' and writes the result to the http response (therefore displaying the result of the command on the user's browser). Let's assume that this takes 3 seconds. Let's assume that there are two users

Why can't I catch SIGINT when asyncio event loop is running?

守給你的承諾、 提交于 2020-01-01 08:22:11
问题 Using Python 3.4.1 on Windows, I've found that while executing an asyncio event loop, my program can't be interrupted (i.e. by pressing Ctrl+C in the terminal). More to the point, the SIGINT signal is ignored. Conversely, I've determined that SIGINT is handled when not in an event loop. Why is it that SIGINT is ignored when executing an asyncio event loop? The below program should demonstrate the problem - run it in the terminal and try to stop it by pressing Ctrl+C, it should keep running:

What is the different between JavaScript Event loop and Node.js Event loop?

£可爱£侵袭症+ 提交于 2020-01-01 03:31:07
问题 In JavaScript, the event loop is used in the engine. Here is one diagram to illustrate it from this article. (source: mybalsamiq.com) For Node.js, the event loop also implemented here. Quoting from this question. The Node.js event loop runs under a single thread, this means the application code you write is evaluated on a single thread. Nodejs itself uses many threads underneath trough libuv, but you never have to deal with with those when writing nodejs code. However, it is still abstract

How many events can Node.js queue?

对着背影说爱祢 提交于 2019-12-31 17:24:59
问题 From what I see, if an event in Node take a "long time" to be dispatched, Node creates some kind of "queue of events", and they are triggered as soon as possible, one by one. How long can this queue be? 回答1: While this may seem like a simple question, it is actually a rather complex problem; unfortunately, there's no simple number that anyone can give you. First: wall time doesn't really play a part in anything here. All events are dispatched in the same fashion, whether or not things are

Why is this microtask executed before macrotask in event loop?

爱⌒轻易说出口 提交于 2019-12-30 11:51:32
问题 My understanding is that the full microtask task queue is processed after each macrotask. If that is the case, why does the setTimeout callback get executed after the Promise microtasks in the following snippet of JavaScript ? console.log('start'); setTimeout(() => { console.log("setTimeout"); }); Promise.resolve().then(function() { console.log('promise'); }); console.log('end'); This outputs the following: > "start" > "end" > "promise" > "setTimeout" Is it because of a ~ 4ms delay imposed by

Eclipse Unhandled event loop exception, no more handles Windows 7

╄→гoц情女王★ 提交于 2019-12-30 08:17:11
问题 My Eclipse is used to develop Android Apps. It worked fine until one day, a Unhandled event loop exception is prompt. The log is shown below. To trigger the error prompt, just unfocus the text editor in eclipse and focus it again, then the prompt is triggered, For example, click on the Package explorer (Red circle) and click on the code (Green circle) in Main.java in Eclipse. (.xml are the same). But, if I unfocus the code by clicking Package Explorer (Red circle) then click on the title of

what is mean by event loop in node.js ? javascript event loop or libuv event loop?

十年热恋 提交于 2019-12-29 01:31:09
问题 In Node.js we a lot talk about the event loop, so I want to know which event loop we are talking about, the Javascript event loop or the libuv event loop ? I guess libuv event loop that provides abstraction for multiple operating system of multiplexing i/o ? Am I right? If not so please explain how this stuff works? I need some internal knowledge, I know what an event loop is, I just want to know how it is connected? 回答1: Currently Node uses the the event loop provided by libuv - namely its

Was the event loop model used in web browsers to control interaction between DOM events concomitantly developed by Brendan Eich with JavaScript?

余生长醉 提交于 2019-12-25 18:53:43
问题 Was the event loop evaluation model used in web browsers to control interaction between DOM events (and later the network) concomitantly developed by Brendan Eich with JavaScript? Or did it pre- or post-date JavaScript? Edit: I am specifically asking about the placement of the event-loop inside browsers. I am aware the event loop is a long-standing invention. 回答1: The event loop predates javascript.. but just by a tiny bit. The event loop was introduced to support progressive download of

What can cause the simple invocation of asyncio.new_event_loop() to hang?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 07:56:16
问题 I am using the following function to force a coroutine to run synchronously: import asyncio import inspect import types from asyncio import BaseEventLoop from concurrent import futures def await_sync(coro: types.CoroutineType, timeout_s: int=None): """ :param coro: a coroutine or lambda loop: coroutine(loop) :param timeout_s: :return: """ loop = asyncio.new_event_loop() # type: BaseEventLoop if not is_awaitable(coro): coro = coro(loop) if timeout_s is None: fut = asyncio.ensure_future(coro,

Running a C++ Event Loop WITHOUT using QT

可紊 提交于 2019-12-23 02:18:46
问题 I have been trying to develop a background Windows application in c++ to capture system wide keystrokes and mouse clicks (no I'm not writing a keystroke logger, just keystroke rates!). For this I have figured out that I need to use Windows Hooks and I came across this excellent video which gave me a basic example. Unfortunately, it uses the QT framework and for licencing (and other time based) reasons, this is not available to me currently. All I need to be able to do is adapt the code so