[PEAK] issues with Trellis event loops and threads

Sergey Schetinin maluke at gmail.com
Sun Jul 20 21:39:00 EDT 2008


There's a problem with using the trellis and activity module in a
multithreaded app. There's a main loop thread with activity.EventLoop
running and there's a rule that runs periodically by rescheduling
itself (in my case it calls wx.ProgressBar.Pulse(), just to give you
an example of why this could be a legitimate use). There's also a
worker thread that initiates this process, but due to EventLoop and
Time being context.Service this doesn't work as expected -- the
dependency on _Timer instance (Time[0.1] for example) created from a
worker thread doesn't schedule a recalculation.

See test in attached file -- it should't hang up, but it does as
do_update rule only runs once.

I tried to fix it by restoring state from the main thread in the
worker thread but it's rather non-trivial as the State instances seem
to rely on a threadlocal data. If there's a proper way to do it, I'd
be happy to learn what it is. Thanks a lot in advance.

-- 
Best Regards,
Sergey Schetinin

http://s3bk.com/ -- S3 Backup
http://word-to-html.com/ -- Word to HTML Converter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_threads.py
Type: text/x-python
Size: 711 bytes
Desc: not available
Url : http://www.eby-sarna.com/pipermail/peak/attachments/20080721/bff1e0bd/test_threads.py


More information about the PEAK mailing list