witten
/
luminotes
Archived
1
0
Fork 0
This repository has been archived on 2023-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
luminotes/controller/Async.py

17 lines
504 B
Python

import cherrypy
def async( method ):
"""
A decorator for a generator method that causes it to be invoked asynchronously. In other words,
whenever a generator method decorated by this decorator is called, its generator is added to
the scheduler for later execution.
This decorator expects a self.scheduler member containing the scheduler to use.
"""
def schedule( self, *args, **kwargs ):
thread = method( self, *args, **kwargs )
self.scheduler.add( thread )
return schedule