Contact: fumanchu@aminus.org

Log in as guest/dejavu to create tickets

Changeset 165

Show
Ignore:
Timestamp:
02/11/06 02:37:21
Author:
fumanchu
Message:

Now distributing recur module with dejavu.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/doc/intro.html

    r164 r165  
    178178installed in <tt>site-packages/dejavu</tt> or some other root python 
    179179path.</p> 
    180  
    181 <p>Dejavu usually depends upon two additional libraries (but you can get by  
    182 without either), <tt>recur.py</tt> and <tt>xray.py</tt>, which are available 
    183 at <tt>http://projects.amor.org/misc/svn/trunk</tt>. Place these two modules 
    184 in your python path, usually site-packages.</p> 
    185180 
    186181<p>Dejavu was built using Python 2.3.2. You should probably use 
  • trunk/doc/storage.html

    r164 r165  
    257257        only persist for the lifetime of the arena.</li> 
    258258    <li><b>Lifetime:</b> Optional. The recurrence string which declares 
    259         how often to sweep Units out of the in-memory cache. If you supply 
    260         this value, you need to grab the <tt>recur</tt> module from 
    261         <tt>http://projects.amor.org/misc/svn/trunk</tt>. The string you 
     259        how often to sweep Units out of the in-memory cache. The string you 
    262260        supply should be one of the following types: 
    263261        <ul> 
  • trunk/engines.py

    r164 r165  
    1313except ImportError: 
    1414    import pickle 
     15import recur 
     16 
    1517import dejavu 
    1618from dejavu import logic 
     
    3436 
    3537 
    36 # The TemporarySweeper class is wrapped in a try/except to 
    37 # allow Dejavu to be deployed without the recur module present. 
    38 # You can obtain the recur module at http://projects.amor.org/misc. 
    39 try: 
    40     import recur 
    41 except ImportError: 
    42     def TemporarySweeper(*args, **kwargs): 
    43         raise AttributeError("The TemporarySweeper class is not available " 
    44                              "because the recur module could not be imported.") 
    45 else: 
    46     class TemporarySweeper(recur.Worker): 
    47         """A worker to sweep out expired TemporaryUnit's.""" 
    48          
    49         def work(self): 
    50             """Start a cycle of scheduled work.""" 
    51             now = datetime.datetime.now() 
    52             f = logic.Expression(lambda x: x.Expiration != None 
    53                                        and x.Expiration <= now) 
    54             box = self.arena.new_sandbox() 
    55              
    56             for cls in self.arena._registered_classes: 
    57                 if issubclass(cls, TemporaryUnit): 
    58                     # Running box.recall will call TemporaryUnit.on_recall, 
    59                     # which should forget expired units. 
    60                     box.recall(cls, f) 
    61             box.flush_all() 
     38class TemporarySweeper(recur.Worker): 
     39    """A worker to sweep out expired TemporaryUnit's.""" 
     40     
     41    def work(self): 
     42        """Start a cycle of scheduled work.""" 
     43        now = datetime.datetime.now() 
     44        f = logic.Expression(lambda x: x.Expiration != None 
     45                                   and x.Expiration <= now) 
     46        box = self.arena.new_sandbox() 
     47         
     48        for cls in self.arena._registered_classes: 
     49            if issubclass(cls, TemporaryUnit): 
     50                # Running box.recall will call TemporaryUnit.on_recall, 
     51                # which should forget expired units. 
     52                box.recall(cls, f) 
     53        box.flush_all() 
    6254 
    6355 
  • trunk/storage/__init__.py

    r164 r165  
    1010    import pickle 
    1111 
    12 from dejavu import logic 
     12from dejavu import logic, recur 
    1313 
    1414 
     
    193193        if lifetime: 
    194194             
    195             import recur 
    196195            class IdleSweeper(recur.Worker): 
    197196                """A worker to sweep out idle Units."""