[ python-Feature Requests-793802 ] class for function calls that are not thread safe

SourceForge.net noreply at sourceforge.net
Tue Nov 11 15:12:18 EST 2003


Feature Requests item #793802, was opened at 2003-08-23 18:02
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=793802&group_id=5470

Category: Threads
Group: None
>Status: Closed
>Resolution: Works For Me
Priority: 5
Submitted By: Markus Elfring (elfring)
Assigned to: Martin v. Löwis (loewis)
Summary: class for function calls that are not thread safe

Initial Comment:
I would like that a class will be added to perform thread unsafe 
function or method calls in an easy way like I describe it in the 
request 
"https://sourceforge.net/mailarchive/forum.php?thread_id=1585197&forum_id=24972" 
for the TCL thread package.
The description 
"http://zthread.sourceforge.net/html/classZThread_1_1SynchronousExecutor.html" 
seems to come near what I want. But I think that there is a little bit 
missing.

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2003-11-11 21:12

Message:
Logged In: YES 
user_id=21627

This cannot be implemented for Python. It requires the
receiving thread to expect the script being sent, which, in
turn, requires an event loop, which Python does not have.

If you are willing to invoke an event loop, you could easily
implement a send function yourself. Just put triples
(callable, *args, **kw) into a Queue, and send an event to
the receiving thread to fetch that triple from the Queue;
the receiving thread would then invoke the callable.

In Python, we can share objects across threads, so passing
script source code is not necessary (although easily
possible - just pass eval as the callable, and a string as
argument)

Closing this as "Works for me", as the original request is
implemented.

----------------------------------------------------------------------

Comment By: Markus Elfring (elfring)
Date: 2003-11-09 19:28

Message:
Logged In: YES 
user_id=572001

Would you like to support that python scripts can be sent to a target thread like that can be done with the TCL function "thread::send"?
http://cvs.sourceforge.net/viewcvs.py/*checkout*/tcl/thread/doc/html/thread.html?rev=1.10

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2003-10-20 23:07

Message:
Logged In: YES 
user_id=21627

That feature is already available. You can easily provide a
module-global mutex that is used to protect all entry points
of some library. See _tkinter for one example, and
socketmodule.c for another.

----------------------------------------------------------------------

Comment By: Markus Elfring (elfring)
Date: 2003-09-07 15:02

Message:
Logged In: YES 
user_id=572001

I am looking for a monitor implementation that has got the scope of a 
library or package and not a single synchronized method or block like it 
is in Java.
A function object will get this monitor as a parameter.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=793802&group_id=5470



More information about the Python-bugs-list mailing list