event-loop

Python asyncio task ordering

走远了吗. 提交于 2019-12-10 19:08:50
问题 I have a question about how the event loop in python's asyncio module manages outstanding tasks. Consider the following code: import asyncio @asyncio.coroutine def a(): for i in range(0, 3): print('a.' + str(i)) yield @asyncio.coroutine def b(): for i in range(0, 3): print('b.' + str(i)) yield @asyncio.coroutine def c(): for i in range(0, 3): print('c.' + str(i)) yield tasks = [ asyncio.Task(a()), asyncio.Task(b()), asyncio.Task(c()), ] loop = asyncio.get_event_loop() loop.run_until_complete

What is the overhead of an asyncio task? [closed]

*爱你&永不变心* 提交于 2019-12-10 17:45:46
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 8 months ago . What is the overhead of any asyncio task in terms of memory and speed? Is it ever worth minimising the number of tasks in cases when they don’t need to run concurrently? 回答1: What is the overhead of any asyncio task in terms of memory and speed? TL;DR The memory overhead appears

python gevent: unexpected output in KeyboardInterrupt

一个人想着一个人 提交于 2019-12-10 17:33:37
问题 Running this code import gevent def f(): while True: gevent.sleep(1) if __name__ == '__main__': tasks = (gevent.spawn(f),) try: gevent.wait(tasks) except KeyboardInterrupt: print("KeyboardInterrupt trapped") and then pressing a Ctrl-C, give me this output: $ python receiver.py ^CKeyboardInterrupt Tue Aug 8 00:56:04 2017 KeyboardInterrupt trapped Why? It seems someone is writing the exit time on output. How can I prevent that KeyboardInterrupt in the first line and the date in the second? 回答1:

Freeze when using tkinter + pyhook. Two event loops and multithreading

Deadly 提交于 2019-12-10 10:19:12
问题 I am writing a tool in python 2.7 registering the amount of times the user pressed a keyboard or mouse button. The amount of clicks will be displayed in a small black box in the top left of the screen. The program registers clicks even when another application is the active one. It works fine except when I move the mouse over the box. The mouse then freezes for a few seconds after which the program works again. If I then move the mouse over the box a second time, the mouse freezes again, but

Possible to run multiple main loops?

我的梦境 提交于 2019-12-09 16:48:22
问题 I'm working with both libfuse and the glib event interface and I've run into an issue where I need to run multiple main loops concurrently (glib's g_main_loop_run and fuse_loop_mt ). I've already attempted to created a detached thread for glib's event loop under a secondary context, e.g.: static void * event_loop(void *arg) { GMainLoop *event_loop; GMainContext *context; context = g_main_context_new(); g_main_context_push_thread_default(context); event_loop = g_main_loop_new(context, FALSE);

What is event loop in ios life cycle and what is its usage and what it does?

我是研究僧i 提交于 2019-12-09 16:08:43
问题 I need to know what the event loop in the ios life cycle does?. Can any one suggest me regarding this?? 回答1: The best answer is probably the one provided by Apple in the "Main event loop" section of the Cocoa Application Competencies for iOS document. In the main event loop, an application continuously routes incoming events to objects for handling and, as a result of that handling, updates its appearance and state. An event loop is simply a run loop: an event-processing loop for scheduling

Does calling QDialog::exec in a slot block the main event loop?

无人久伴 提交于 2019-12-09 12:57:57
问题 My Qt application's main window is a normal QMainWindow subclass. In that window I have a few buttons; each has its clicked signal connected its own slot, and each slot creates a different QDialog like so: void onButtonA_clicked() { MyADialog* dialog = new MyADialog(this); dialog->exec(); delete dialog; } I've been reading this article: https://wiki.qt.io/Threads_Events_QObjects#Events_and_the_event_loop and the author says you should never ever block the event loop which got me concerned;

Basic Event Loop in Python [duplicate]

给你一囗甜甜゛ 提交于 2019-12-09 12:54:23
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Event loop implementation for Python 3? I am trying to implement an event loop in python2.7. I would like to be able to trigger events based on a time event and as a result of another action taking place. I understand I can make use of select to do something similar to this. Is this the right way forwards or is there a better way which I am missing? 回答1: An event loop is a loop which handles / deals with events.

How to show a rapidly changing image in an SWT canvas? ( paintControl() listener method is not being called rapidly)

牧云@^-^@ 提交于 2019-12-08 00:08:46
问题 I'm using a MouseMoveListener on a composite to update the image on another canvas. Basically, if the user drags Composite1 to somewhere on his screen, that will call the mouseMoveEventListener everytime the mouse moves, which will get the x,y location of the mouse, take a screenshot using Awt.robot.captureScreenRegion , and try to update the image of Canvas1 by calling its repaint() method. The purpose is just to show the user a preview of what's under the composite as he's dragging it. Here

How to run the Tornado event loop alongside a Kivy GUI?

北城余情 提交于 2019-12-07 15:43:00
问题 My client application uses a Kivy GUI (Kivy has its own event loop) and connects to the server using the WebSocket protocol with Tornado (Tornado also has an event loop). That's why the connection part is asynchronous. I want the user to interact with the UI while a Tornado client is running an infinite asynchronous loop of listening for server messages. Here's some example code: client_test.py from tornado.ioloop import IOLoop from tornado.websocket import websocket_connect class