Select Git revision
-
DFNVC authored
Meetings können nicht mehr versehentlich gelöscht werden, falls noch Aufzeichnungen enthalten sind. Neue Veranstalter-Löschfunktion für Aufzeichungen. Eine Adobe-Connect-Aktivität kann nicht mehr erzeugt werden, wenn die angegebene Meeting-URL bereits existiert.
DFNVC authoredMeetings können nicht mehr versehentlich gelöscht werden, falls noch Aufzeichnungen enthalten sind. Neue Veranstalter-Löschfunktion für Aufzeichungen. Eine Adobe-Connect-Aktivität kann nicht mehr erzeugt werden, wenn die angegebene Meeting-URL bereits existiert.
README.md 3.73 KiB
pikatasks
pikatasks is a minimalistic library that allows you to run remote tasks easily. There's also a Django integration.
Requirements
pip install pika
- RabbitMQ as message broker
How-to
Import:
import pikatasks
Configure:
pikatasks.settings.BROKER_HOST = "localhost"
pikatasks.settings.BROKER_PORT = 5672 # change to 5671 if using SSL
pikatasks.settings.SSL_ENABLED = False # change to True in production :)
pikatasks.settings.VIRTUAL_HOST = "/" # rabbitmq default vhost
pikatasks.settings.USERNAME = "admin" # too lazy to change!
pikatasks.settings.PASSWORD = "qwertz" # easy to remember!
Or in Django settings:
PIKATASKS_BROKER_HOST = "localhost"
PIKATASKS_BROKER_PORT = 5672
...
Implement a task (server):
@pikatasks.task
def hello(something):
msg = "Hello, " + something + "!"
print(msg)
return msg
- The task name (and the queue name) will be the same as the function name. If you want to specify a custom task (and queue) name, use
@pikatasks.task("my_task_name")
. - Note: you will need a queue with exactly the same name as the task. See section: Queues and Permissions.
Start a server:
pikatasks.worker.start(tasks=[hello])
Run a task (client):
To simply run a task:
pikatasks.run("hello", something="World")
Run a task and get its result:
result = pikatasks.rpc("hello", something="World")
print(result)
# >>> "Hello, World!"
Catch exceptions:
if a task raises an exception on the server, pikatask.rpc()
call on the client will also raise an exception. Full exception message is not sent for security/isolation reasons.
try:
pikatasks.run("hello", something=42)
except pikatasks.RPCError as e:
print(e)
# >>> Task hello raised TypeError (see worker log for details).
# Note: TypeError was raised when the server was running: "Hello, " + 42 + "!"
Queues and Permissions
Queues and exchanges:
With AMQ, messages first arrive to exchanges
, then broker distributes them to to queues
using routing keys
. If you are not sure what it is all about, read this tutorial first and further RabbitMQ documentation if needed.
Queues and Tasks:
- pikatasks requires a separate queue for each task.
queue name == task name
- You need to create these queues by yourself.