~eeejay/checkbox/gtkbuilder

« back to all changes in this revision

Viewing changes to checkbox/reactor.py

  • Committer: Marc Tardif
  • Date: 2009-06-01 18:29:12 UTC
  • mfrom: (540.1.4 checkbox_0.8-ppa6)
  • Revision ID: marc.tardif@canonical.com-20090601182912-g2scwp2y5acs7w65
Fixed reactor to be thread safe.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#
19
19
import re
20
20
import logging
 
21
import threading
21
22
 
22
23
from checkbox.lib.log import format_object
23
24
 
43
44
 
44
45
    def __init__(self):
45
46
        self._event_handlers = {}
46
 
        self._event_stack = []
 
47
        self._local = threading.local()
 
48
 
 
49
    @property
 
50
    def _event_stack(self):
 
51
        try:
 
52
            return self._local._event_stack
 
53
        except AttributeError:
 
54
            self._local._event_stack = []
 
55
            return self._local._event_stack
47
56
 
48
57
    def call_on(self, event_type, handler, priority=0):
49
58
        pair = (handler, priority)