‘Queued’ means the service stores the function calls in a Queue and the execution order is according to their priorities.
Internally the commands are forwarded to a PriorityQueue, which is not process safe.
Using a separate result queue the return values are passed to the according callers.
A QueuedService wraps a normal Service. The priority decorator is used to define priorities for the functions. Higher priorities lead to earlier execution. The default priority for not decorated functions is 0.
Example:
class ExampleService(object):
@priority(5)
def fast_operation(self):
# do fast stuff
@priority(10)
def slow_operation(self):
# do slow stuff
The following call sequence:
service.slow_operation()
service.fast_operation()
service.slow_operation()
service.fast_operation()
service.slow_operation()
service.fast_operation()
leads to an execution order of:
Derive a class from QueuedService and add a CLASS property, which contains the class of the object to be wrapped.
Example:
class QueuedExampleService(QueuedService):
CLASS = TestObject
Note
init_resources() and close_resources() are called on initialization and closing if provided by the wrapped object
Note
For an extensive example see Queued Service Example.
Using callbacks does not differ from the normal use, but using Events does. It works to register() and unregister() as usual, but it is not possible to call trigger() remotely. This will cause a ForbiddenAttributeAccessError to be raised. (See Queued Callback Example)
Warning
It is not possible to wrap a CallbackObject or CallbackService or a subclass of them by a QueuedService!
The Autoproxy feature is implemented for QueuedService, too. If an object that is wrapped by the QueuedService is passed to another process. It is replaced by a Proxy to the QueuedService