libev loop in a Python thread
Marc Lehmann
schmorp at schmorp.de
Mon Jun 7 08:20:39 CEST 2010
On Sun, Jun 06, 2010 at 10:18:34PM +0200, "Jonas H." <jonas at lophus.org> wrote:
> Unfortunately it seems like the thread that runs the libev mainloop
> blocks any other Python thread: Once the libev loop has been started,
Python doesn't support threads running in parallel, if one thread blocks
the process, no other threads can run.
There are hacks around this, and these would need to be implemented in the
python interface (it's not a libev issue).
However, to get it working crash-free the python-interface would need to
do considerable effort, so it's not trivial (or you get the same crash
guarantees as with C :).
> I tried threading priorities, but that didn't change anything.
Yeah, it's a limitation in cpython itself - it only supports cooperative
threads.
> worry about -- but could it be that something deadlocks there? Or is it
> just libev that doesn't give the poor(ly implemented) Python interpreter
> a chance of taking back control? ;-)
The python interpreter might be poorly implemented in other respects, but
not in this one: no high level language offers true concurrent threads,a
nd the reason are deep and complicated (you can basiclaly choose between
it being dog-slow, or crashing in even more unexpected ways than in raw C,
or not running concurrently).
The python model is quite alright - the libev interface would need to
cooperatively give up the cpu.
--
The choice of a Deliantra, the free code+content MORPG
-----==- _GNU_ http://www.deliantra.net
----==-- _ generation
---==---(_)__ __ ____ __ Marc Lehmann
--==---/ / _ \/ // /\ \/ / schmorp at schmorp.de
-=====/_/_//_/\_,_/ /_/\_\
More information about the libev
mailing list