[Zope-dev] Using Threads in Zope-Product

Ulrich Eck ueck@net-labs.de
Thu, 7 Jun 2001 16:32:00 +0200


Hi zopistas,

I currently work on a PythonProduct called JobManager.

The purpose of this Product is, that one can define a hierachical set of
PythonScripts (Jobs with SubJobs)
that are executed in seperate Threads by call or scheduled.

This is intended for use with expensive Database-Update or my ServiceManager
(XML-RPC Server/Client)
which need to much time to complete, that a user can't / doesn't want to
wait for completion.

Now there is some trikyness in programming Threads in zope ..
because I wanted the thread-instances to be accessible throug zope as long
as they are running

- ZODB uses the module thread (start_new_thread, aquire/release_lock)
- Scheduler (i found it in DC-CVS) is probably not finished and uses thread
as well.
  the thread instance is not accessible from Zope as far as i can see

- ZExternalNewManager uses the module threading (Thread(...))
   the thread-instance is stored as volatile attribute (_v_threadinstance)

Using the threading library would be most convinient but the Objects from
threading are not pickable.

I need Locks and would like to have Conditions to control the behavior of
the JobManager,
so I tried to make a copy of threading and added Persistence ..
(derived all classes from ZODB.Persistent, but doesn't work)

 with no success.


Is it basically possible .. does it make sense to store the instance of a
Thread as an attribute of
a ZODB-stored Object ???

If yes .. what changes are neccesary to make threading persistant

If no .. has anybody else done such a thing with success ??

any comment welcome

thanks
Ulrich Eck
net-labs