On Mon, 13 Mar 2006 21:57:59 -0500, Raymond Hettinger wrote:
> Think of it as "non-cooperative"
> multi-threading. While this is a somewhat rough approach, it is dramatically
> simpler than the alternatives (i.e. wrapping locks around every access to a
> resource or feeding all resource requests to a separate thread via a Queue).
Why is that actually more difficult to write? Consider
res_lock = Lock()
res = ...
with locked(res_lock):
do_something(res)
It is only about supplying the correct lock at the right time. Or even this
could work:
res = ... # implements lock()/unlock()
with locked(res):
do_something(res)
Directly exposing the GIL (or some related system) for such matters does
not seem to be a good reason for a novice to let him stop all threads.
Kind regards,
Alexander
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com