File tree Expand file tree Collapse file tree 3 files changed +54
-2
lines changed Expand file tree Collapse file tree 3 files changed +54
-2
lines changed Original file line number Diff line number Diff line change @@ -2250,7 +2250,7 @@ async def create_task(
22502250 task_id : Optional [str ] = None ,
22512251 name : Optional [str ] = None ,
22522252 offset : Optional [int ] = None ,
2253- params : Optional [str ] = None ,
2253+ params : Optional [Json ] = None ,
22542254 period : Optional [int ] = None ,
22552255 ) -> Result [Json ]:
22562256 """Create a new task.
@@ -2262,7 +2262,7 @@ async def create_task(
22622262 name (str | None): The name of the task.
22632263 offset (int | None): The offset in seconds after which the task should
22642264 start executing.
2265- params (str | None): Parameters to be passed to the command.
2265+ params (dict | None): Parameters to be passed to the command.
22662266 period (int | None): The number of seconds between the executions.
22672267
22682268 Returns:
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ Contents
7373 compression
7474 serialization
7575 backup
76+ task
7677 errors
7778 errno
7879 logging
Original file line number Diff line number Diff line change 1+ Tasks
2+ -----
3+
4+ ArangoDB can schedule user-defined Javascript snippets as one-time or periodic
5+ (re-scheduled after each execution) tasks. Tasks are executed in the context of
6+ the database they are defined in.
7+
8+ **Example: **
9+
10+ .. code-block :: python
11+
12+ from arangoasync import ArangoClient
13+ from arangoasync.auth import Auth
14+
15+ # Initialize the client for ArangoDB.
16+ async with ArangoClient(hosts = " http://localhost:8529" ) as client:
17+ auth = Auth(username = " root" , password = " passwd" )
18+
19+ # Connect to "test" database as root user.
20+ db = await client.db(" test" , auth = auth)
21+
22+ # Create a new task which simply prints parameters.
23+ await db.create_task(
24+ name = " test_task" ,
25+ command = """
26+ var task = function(params){
27+ var db = require('@arangodb');
28+ db.print(params);
29+ }
30+ task(params);
31+ """ ,
32+ params = {" foo" : " bar" },
33+ offset = 300 ,
34+ period = 10 ,
35+ task_id = " 001"
36+ )
37+
38+ # List all active tasks
39+ tasks = await db.tasks()
40+
41+ # Retrieve details of a task by ID.
42+ details = await db.task(" 001" )
43+
44+ # Delete an existing task by ID.
45+ await db.delete_task(' 001' , ignore_missing = True )
46+
47+
48+ .. note ::
49+ When deleting a database, any tasks that were initialized under its context
50+ remain active. It is therefore advisable to delete any running tasks before
51+ deleting the database.
You can’t perform that action at this time.
0 commit comments