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(
2250
2250
task_id : Optional [str ] = None ,
2251
2251
name : Optional [str ] = None ,
2252
2252
offset : Optional [int ] = None ,
2253
- params : Optional [str ] = None ,
2253
+ params : Optional [Json ] = None ,
2254
2254
period : Optional [int ] = None ,
2255
2255
) -> Result [Json ]:
2256
2256
"""Create a new task.
@@ -2262,7 +2262,7 @@ async def create_task(
2262
2262
name (str | None): The name of the task.
2263
2263
offset (int | None): The offset in seconds after which the task should
2264
2264
start executing.
2265
- params (str | None): Parameters to be passed to the command.
2265
+ params (dict | None): Parameters to be passed to the command.
2266
2266
period (int | None): The number of seconds between the executions.
2267
2267
2268
2268
Returns:
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ Contents
73
73
compression
74
74
serialization
75
75
backup
76
+ task
76
77
errors
77
78
errno
78
79
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