mirror of
				https://github.com/Mikaela/Limnoria.git
				synced 2025-11-04 01:27:21 +01:00 
			
		
		
		
	Add support for arguments to addPeriodicEvent callbacks.
This commit is contained in:
		
							parent
							
								
									97b48abaa2
								
							
						
					
					
						commit
						30c56ae19f
					
				@ -109,11 +109,11 @@ class Schedule(drivers.IrcDriver):
 | 
			
		||||
        f = self.removeEvent(name)
 | 
			
		||||
        self.addEvent(f, t, name=name)
 | 
			
		||||
 | 
			
		||||
    def addPeriodicEvent(self, f, t, name=None, now=True):
 | 
			
		||||
    def addPeriodicEvent(self, f, t, name=None, now=True, args=[], kwargs={}):
 | 
			
		||||
        """Adds a periodic event that is called every t seconds."""
 | 
			
		||||
        def wrapper():
 | 
			
		||||
            try:
 | 
			
		||||
                f()
 | 
			
		||||
                f(*args, **kwargs)
 | 
			
		||||
            finally:
 | 
			
		||||
                # Even if it raises an exception, let's schedule it.
 | 
			
		||||
                return self.addEvent(wrapper, time.time() + t, name)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user