green-threads

Tkinter locks Python when an icon is loaded and tk.mainloop is in a thread

a 夏天 提交于 2019-11-28 09:24:12
Here's the test case... import Tkinter as tk import thread from time import sleep if __name__ == '__main__': t = tk.Tk() thread.start_new_thread(t.mainloop, ()) # t.iconbitmap('icon.ico') b = tk.Button(text='test', command=exit) b.grid(row=0) while 1: sleep(1) This code works. Uncomment the t.iconbitmap line and it locks. Re-arrange it any way you like; it will lock. How do I prevent tk.mainloop locking the GIL when there is an icon present? The target is win32 and Python 2.6.2. codeape I believe you should not execute the main loop on a different thread. AFAIK, the main loop should be

Green-threads and thread in Python

廉价感情. 提交于 2019-11-27 09:41:21
问题 As Wikipedia states: Green threads emulate multi-threaded environments without relying on any native OS capabilities, and they are managed in user space instead of kernel space, enabling them to work in environments that do not have native thread support. Python's threads are implemented as pthreads (kernel threads) , and because of the global interpreter lock (GIL), a Python process only runs one thread at a time. [ QUESTION ] But in the case of Green-threads (or so-called greenlet or

Tkinter locks Python when an icon is loaded and tk.mainloop is in a thread

ε祈祈猫儿з 提交于 2019-11-26 21:05:38
问题 Here's the test case... import Tkinter as tk import thread from time import sleep if __name__ == '__main__': t = tk.Tk() thread.start_new_thread(t.mainloop, ()) # t.iconbitmap('icon.ico') b = tk.Button(text='test', command=exit) b.grid(row=0) while 1: sleep(1) This code works. Uncomment the t.iconbitmap line and it locks. Re-arrange it any way you like; it will lock. How do I prevent tk.mainloop locking the GIL when there is an icon present? The target is win32 and Python 2.6.2. 回答1: I

Technically, why are processes in Erlang more efficient than OS threads?

放肆的年华 提交于 2019-11-26 15:35:37
Erlang's Characteristics From Erlang Programming (2009): Erlang concurrency is fast and scalable. Its processes are lightweight in that the Erlang virtual machine does not create an OS thread for every created process. They are created, scheduled, and handled in the VM, independent of underlying operating system. As a result, process creation time is of the order of microseconds and independent of the number of concurrently existing processes. Compare this with Java and C#, where for every process an underlying OS thread is created: you will get some very competitive comparisons, with Erlang

Technically, why are processes in Erlang more efficient than OS threads?

对着背影说爱祢 提交于 2019-11-26 04:29:18
问题 Erlang\'s Characteristics From Erlang Programming (2009): Erlang concurrency is fast and scalable. Its processes are lightweight in that the Erlang virtual machine does not create an OS thread for every created process. They are created, scheduled, and handled in the VM, independent of underlying operating system. As a result, process creation time is of the order of microseconds and independent of the number of concurrently existing processes. Compare this with Java and C#, where for every