> Could you please post a code snippet so that I can see how you
> implemented threading?

WebKit did the actual threading once I configured it to
have multiple threads.  After that, I had to make certain
that each thread had it's own data dictionary.

I shamelessly took the idea from ActiveState's web site at
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66429

I have functions that return this thread's data dictionary,
or another thread's data dictionary.  Makes it convenient for
the threads to talk to each other.  Make certain to delete
the dictionary for each thread when it sleeps.  My code is:

if not vars().has_key("_tss"):
    _tss = {}
if not vars().has_key("_tss_lock"):
    tss_lock = thread.allocate_lock()


# get's specified thread's data dictionary
def get_tss_id(thread_id):
    """Return a thread-specific storage dictionary."""
    tss = _tss.get(thread_id)
    if tss is None: # First time being called by this thread.
        try: # Entering critical section.
            tss_lock.acquire()
            _tss[thread_id] = tss = {} # Create a thread-specific dictionary.
        finally:
            tss_lock.release()
    return tss

# gives this thread's data dictionary
def get_tss():
    """Return a thread-specific storage dictionary."""
    return get_tss_id(thread.get_ident()) # Identify the calling thread.

# resets a specified thread's data dictionary
def reset_tss(thread_id):
    if _tss.has_key(thread_id):
        del _tss[thread_id]


     James Phillips
     http://zunzun.com



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to