Questions tagged [event-loop]

Event loop refers to an infinite cycle of actions which is used for processing data based on callbacks and messages.

An event loop watches for I/O and timer state changes. It queues functions while waiting for unavailable resources, then dispatches them when resources are available.

References

1046 questions
6
votes
1 answer

The C++11 way to build an event loop

What's the basic structure of a event loop system in C++11? How are the key elements (such as message queue, message dispatcher, signal) implemented? For example, do I still need a std::queue, a std::mutex and a std::condition_variable as…
GuLearn
  • 1,814
  • 2
  • 18
  • 32
6
votes
4 answers

No event loop graphics in Perl plus X Window?

On the Apple II BASIC in the 1980s, you would use "HGR", to get to a screen, "HCOLOR" would set a color, and "HPLOT" would plot points. You could also manipulate the screen byte data, and you wouldn't have to hand off program control to any event…
6
votes
1 answer

Query about the event loop of Nodejs

It is well known that Nodejs is handling all events in the background loop. But how can I monitor all the active events and is it potential risk of out of memory or dead lock?
Mike Huang
  • 257
  • 1
  • 2
  • 10
5
votes
1 answer

Update/render game objects using Qt

I'd like to know how to update and render game objects when using Qt. E.g. with a typical game you'd have an event loop, but Qt just has exec(). What is the correct way to update and render game objects using Qt? How do I do things like get the time…
Mitch
  • 23,716
  • 9
  • 83
  • 122
5
votes
2 answers

Why isn't my class attribute preserved when using multiprocessing?

I have the following class in a FastAPI application: import asyncio import logging from multiprocessing import Lock, Process from .production_status import Job as ProductionStatusJob class JobScheduler: loop = None logger =…
5
votes
1 answer

QNetworkReply emits error signal twice when ContentNotFoundError occures when event loop is started in error slot

Im using QtSDK 4.7.3 I am doing this in (void test()): mgr = new QNetworkAccessManager(); reply = mgr->get(QNetworkRequest(QUrl("http://developer.qt.nokia.com/fileNotExisting.txt"))); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), …
Elon Mallin
  • 345
  • 4
  • 12
5
votes
1 answer

How does asyncio main thread manage running either the event loop and coroutines at the same time?

Firs of all, I apologize for my English. I am learning python asyncio module and I get confused at some point. I learn from the doc that the main purpose of the event loop is to schedule coroutines for running, open newtwork I/O... A running…
user13837279
  • 77
  • 1
  • 3
5
votes
2 answers

How is timing of `setImmediate()` and `setTimeout()` bound by the performance of the process?

I am confused by the following paragraph of the Node.js documentation. setImmediate() vs setTimeout() ... The order in which the timers are executed will vary depending on the context in which they are called. If both are called from within the…
nalzok
  • 14,965
  • 21
  • 72
  • 139
5
votes
1 answer

How to break the match case but not the while loop

I'm trying to use match case when checking the value in event loop. However break not only break the match case, but break the event loop too. This is the code while True: # Some code stuff here if event == "#PassSign": # Some code…
Franky Ray
  • 83
  • 1
  • 6
5
votes
1 answer

the callback function of addEventListener is queued in macro task queue in Event Loop?

I know that the callback function of setTimeout, setInterval, setImmediate api is queued in macro task queue. But, I'm not sure about addEventListener. Is the callback function of addEventListener is queued in macro task queue? Check please :D
Byeongin Yoon
  • 3,233
  • 6
  • 26
  • 44
5
votes
3 answers

Repeat python function at every system clock minute

I've seen that I can repeat a function with python every x seconds by using a event loop library in this post: import sched, time s = sched.scheduler(time.time, time.sleep) def do_something(sc): print("Doing stuff...") # do your stuff …
Jepessen
  • 11,744
  • 14
  • 82
  • 149
5
votes
1 answer

Using nested asyncio.gather() inside another asyncio.gather()

I have a class with various methods. I have a method in that class something like : class MyClass: async def master_method(self): tasks = [self.sub_method() for _ in range(10)] results = await asyncio.gather(*tasks) async def…
KZiovas
  • 3,491
  • 3
  • 26
  • 47
5
votes
5 answers

How to avoid to start hundreds of threads when starting (very short) actions at different timings in the future

I use this method to launch a few dozen (less than thousand) of calls of do_it at different timings in the future: import threading timers = [] while True: for i in range(20): t = threading.Timer(i * 0.010, do_it, [i]) # I pass the…
Basj
  • 41,386
  • 99
  • 383
  • 673
5
votes
0 answers

What are SelectorEventLoop and ProactorEventLoop in python asyncio

What exactly are SelectorEventLoop and ProactorEventLoop? How are they different? I was testing the use of asyncio and aiohttp in python on Windows, then got an error RuntimeError: Event loop is closed. Looked up and found a workaround, but I did…
koyamashinji
  • 535
  • 1
  • 6
  • 19
5
votes
1 answer

How does the event loop in the browser deal with the event queue, job queue, render queue at the same time?

Last week I started learning Javascript back-end with nodejs. While working with async functions, I wanted to understand this in all aspect and started doing research on this subject. I found Jake Archibald's presentation in jsconf and I tried to…
BarkinM
  • 51
  • 2