@@ -94,7 +94,8 @@ Set number of parallel worker threads (1-16).
9494
9595- ** CPU-bound** : Match CPU cores (4-8)
9696- ** I/O-bound** : Can exceed cores (8-16)
97- - ** Default** : 4
97+ - ** Default** : Number of CPU cores
98+ - Raises ` ValueError ` if ` level ` is not between 1 and 16
9899
99100** Example:**
100101
@@ -139,14 +140,14 @@ async_exec = db.async_executor().set_commit_every(10000)
139140### set_transaction_use_wal
140141
141142``` python
142- async_exec.set_transaction_use_wal(enabled : bool ) -> AsyncExecutor
143+ async_exec.set_transaction_use_wal(use_wal : bool ) -> AsyncExecutor
143144```
144145
145146Enable or disable Write-Ahead Log for transactions.
146147
147148** Parameters:**
148149
149- - ` enabled ` (bool): True to enable WAL (durability), False for speed
150+ - ` use_wal ` (bool): True to enable WAL (durability), False for speed
150151
151152** Returns:**
152153
@@ -166,14 +167,14 @@ async_exec = db.async_executor().set_transaction_use_wal(False)
166167### set_back_pressure
167168
168169``` python
169- async_exec.set_back_pressure(threshold : int ) -> AsyncExecutor
170+ async_exec.set_back_pressure(percentage : int ) -> AsyncExecutor
170171```
171172
172173Set queue back-pressure threshold (0-100).
173174
174175** Parameters:**
175176
176- - ` threshold ` (int): Percentage (0=disabled, 100=always)
177+ - ` percentage ` (int): Percentage (0- 100). Raises ` ValueError ` if outside 0-100
177178
178179** Returns:**
179180
@@ -209,182 +210,173 @@ async_exec = (db.async_executor()
209210
210211## Operation Methods
211212
212- ### create_record
213+ The async executor schedules SQL/OpenCypher work and a small set of record-level graph
214+ and time-series operations. There are no ` create_record ` /` update_record ` /` delete_record `
215+ methods; perform inserts, updates, and deletes through ` command(...) ` with SQL.
216+
217+ ### command
213218
214219``` python
215- async_exec.create_record(
216- record,
217- callback: Optional[Callable] = None
220+ async_exec.command(
221+ language: str ,
222+ command_text: str ,
223+ callback: Optional[Callable[[Any], None ]] = None ,
224+ args: Optional[Sequence[Any]] = None ,
225+ error_callback: Optional[Callable[[Exception ], None ]] = None ,
226+ ** params,
218227)
219228```
220229
221- Schedule asynchronous record creation.
222-
223- !!! note "Wrapper-specific API"
224- ` AsyncExecutor.create_record() ` and ` update_record() ` operate on record wrapper
225- objects. For non-async CRUD examples elsewhere in the docs, prefer SQL/OpenCypher.
230+ Execute an async command (INSERT/UPDATE/DELETE/DDL). The callback is optional.
226231
227232** Parameters:**
228233
229- - ` record ` : Document, Vertex, or Edge object to create
230- - ` callback ` (Optional[ Callable] ): Success callback
234+ - ` language ` (str): Command language (` "sql" ` , ` "opencypher" ` , etc.)
235+ - ` command_text ` (str): Command string
236+ - ` callback ` (Optional[ Callable] ): Optional callback invoked with each result row
237+ - ` args ` (Optional[ Sequence] ): Positional parameters (use ` ? ` placeholders)
238+ - ` error_callback ` (Optional[ Callable] ): Optional per-operation error callback
239+ - ` **params ` : Named parameters (use ` :name ` placeholders)
240+
241+ !!! note "args vs. params"
242+ Pass either positional ` args ` or named ` **params ` , not both. Mixing them raises
243+ ` ValueError ` .
231244
232245** Example:**
233246
234247``` python
235248async_exec = db.async_executor()
236249
250+ # Async inserts via SQL (no create_record helper exists)
237251for i in range (10000 ):
238- vertex = db.new_vertex(" User" )
239- vertex.set(" userId" , i)
240- vertex.set(" name" , f " User { i} " )
241- async_exec.create_record(vertex)
242-
243- async_exec.wait_completion()
244- async_exec.close()
245- ```
246-
247- ---
252+ async_exec.command(
253+ " sql" ,
254+ " INSERT INTO User SET userId = :id, name = :name" ,
255+ id = i,
256+ name = f " User { i} " ,
257+ )
248258
249- ### update_record
259+ # Async update
260+ async_exec.command(" sql" , " UPDATE User SET active = true WHERE active = false" )
250261
251- ``` python
252- async_exec.update_record(
253- record,
254- callback: Optional[Callable] = None
262+ # Async delete with positional args
263+ async_exec.command(
264+ " sql" ,
265+ " DELETE FROM LogEntry WHERE timestamp < ?" ,
266+ args = [cutoff_date],
255267)
256- ```
257-
258- Schedule asynchronous record update.
259-
260- ** Parameters:**
261-
262- - ` record ` : Document, Vertex, or Edge object to update
263- - ` callback ` (Optional[ Callable] ): Success callback
264-
265- ** Example:**
266-
267- ``` python
268- # Query records
269- results = list (db.query(" sql" , " SELECT FROM User WHERE active = false" ))
270-
271- async_exec = db.async_executor()
272-
273- for result in results:
274- element = result.get_element()
275- mutable = element.modify()
276- mutable.set(" active" , True )
277- async_exec.update_record(mutable)
278268
279269async_exec.wait_completion()
280270async_exec.close()
281271```
282272
283273---
284274
285- ### delete_record
275+ ### query
286276
287277``` python
288- async_exec.delete_record(
289- record,
290- callback: Optional[Callable] = None
278+ async_exec.query(
279+ language: str ,
280+ query_text: str ,
281+ callback: Callable[[Any], None ],
282+ args: Optional[Sequence[Any]] = None ,
283+ error_callback: Optional[Callable[[Exception ], None ]] = None ,
284+ ** params,
291285)
292286```
293287
294- Schedule asynchronous record deletion .
288+ Execute an async query with a callback invoked for each result row .
295289
296290** Parameters:**
297291
298- - ` record ` : Document, Vertex, or Edge object to delete
299- - ` callback ` (Optional[ Callable] ): Success callback
292+ - ` language ` (str): Query language (` "sql" ` , ` "opencypher" ` , etc.)
293+ - ` query_text ` (str): Query string
294+ - ` callback ` (Callable): Callback receiving each result row
295+ - ` args ` (Optional[ Sequence] ): Positional parameters
296+ - ` error_callback ` (Optional[ Callable] ): Optional per-operation error callback
297+ - ` **params ` : Named parameters
300298
301299** Example:**
302300
303301``` python
304- # Delete old records
305- to_delete = list (db.query(" sql" , " SELECT FROM LogEntry WHERE timestamp < ?" ,
306- cutoff_date))
302+ def process_row (row ):
303+ print (row.get(" name" ))
307304
308305async_exec = db.async_executor()
309-
310- for result in to_delete:
311- element = result.get_element()
312- async_exec.delete_record(element)
313-
306+ async_exec.query(" sql" , " SELECT FROM User WHERE age > 18" , process_row)
314307async_exec.wait_completion()
315308async_exec.close()
316309```
317310
318311---
319312
320- ### query
313+ ### new_edge
321314
322315``` python
323- async_exec.query(
324- language: str ,
325- query: str ,
326- callback: Callable,
327- ** params
316+ async_exec.new_edge(
317+ source_vertex,
318+ edge_type: str ,
319+ destination_vertex_or_rid,
320+ light: bool = False ,
321+ callback: Optional[Callable[[Any, bool , bool ], None ]] = None ,
322+ ** properties,
328323)
329324```
330325
331- Execute async query.
332-
333- ** Parameters: **
326+ Asynchronously create an edge between an existing source vertex and a destination
327+ vertex (or RID string). The optional callback receives `(edge, created_source_vertex,
328+ created_dest_vertex)`.
334329
335- - ` language ` (str): Query language ("sql", "opencypher", etc.)
336- - ` query ` (str): Query string
337- - ` callback ` (Callable): Callback for query results
338- - ` **params ` : Query parameters
330+ ---
339331
340- ** Example: **
332+ ### transaction
341333
342334``` python
343- def process_results (resultset ):
344- for result in resultset:
345- print (result.get(" name" ))
346-
347- async_exec = db.async_executor()
348- async_exec.query(" sql" , " SELECT FROM User WHERE age > 18" , process_results)
349- async_exec.wait_completion()
350- async_exec.close()
335+ async_exec.transaction(
336+ tx_block: Callable[[], None ],
337+ retries: Optional[int ] = None ,
338+ ok_callback: Optional[Callable[[], None ]] = None ,
339+ error_callback: Optional[Callable[[Exception ], None ]] = None ,
340+ slot: Optional[int ] = None ,
341+ )
351342```
352343
344+ Run ` tx_block ` inside an async transaction scope, optionally with automatic retries and
345+ completion callbacks.
346+
353347---
354348
355- ### command
349+ ### scan_type
356350
357351``` python
358- async_exec.command (
359- language : str ,
360- command: str ,
361- callback: Callable ,
362- ** params
352+ async_exec.scan_type (
353+ type_name : str ,
354+ callback: Callable[[Any], bool ] ,
355+ polymorphic: bool = True ,
356+ error_callback: Optional[Callable[[Any, Exception ], bool ]] = None ,
363357)
364358```
365359
366- Execute async command.
367-
368- ** Parameters:**
369-
370- - ` language ` (str): Command language ("sql", etc.)
371- - ` command ` (str): Command string
372- - ` callback ` (Callable): Callback for command results
373- - ` **params ` : Command parameters
360+ Asynchronously scan all records of a type, invoking ` callback ` per record. Returning
361+ ` False ` from the callback stops the scan.
374362
375363## Status Methods
376364
377365### wait_completion
378366
379367``` python
380- async_exec.wait_completion(timeout : Optional[float ] = None )
368+ async_exec.wait_completion(timeout_ms : Optional[int ] = None )
381369```
382370
383371Wait for all pending operations to complete.
384372
385373** Parameters:**
386374
387- - ` timeout ` (Optional[ float] ): Max wait time in seconds (None = forever)
375+ - ` timeout_ms ` (Optional[ int] ): Max wait time in milliseconds (None = forever)
376+
377+ ** Raises:**
378+
379+ - ` TimeoutError ` : If the timeout elapses before completion
388380
389381** Note:** Always call before closing executor or database.
390382
@@ -393,14 +385,13 @@ Wait for all pending operations to complete.
393385``` python
394386async_exec = db.async_executor()
395387
396- # Queue operations
388+ # Queue operations via SQL
397389for i in range (10000 ):
398- vertex = db.new_vertex(" User" )
399- vertex.set(" userId" , i)
400- async_exec.create_record(vertex)
390+ async_exec.command(" sql" , " INSERT INTO User SET userId = :id" , id = i)
401391
402- # Wait for all to complete
392+ # Wait for all to complete (wait forever, or pass milliseconds)
403393async_exec.wait_completion()
394+ async_exec.wait_completion(30000 ) # wait at most 30 seconds
404395
405396# Now safe to close
406397async_exec.close()
@@ -477,13 +468,15 @@ async_exec = (db.async_executor()
477468# Measure performance
478469start = time.time()
479470
480- # Create 100K vertices asynchronously
471+ # Create 100K vertices asynchronously via SQL
481472for i in range (100000 ):
482- vertex = db.new_vertex(" Product" )
483- vertex.set(" productId" , i)
484- vertex.set(" name" , f " Product { i} " )
485- vertex.set(" price" , i * 10.5 )
486- async_exec.create_record(vertex)
473+ async_exec.command(
474+ " sql" ,
475+ " INSERT INTO Product SET productId = :id, name = :name, price = :price" ,
476+ id = i,
477+ name = f " Product { i} " ,
478+ price = i * 10.5 ,
479+ )
487480
488481# Wait for completion
489482async_exec.wait_completion()
@@ -518,9 +511,7 @@ sync_time = time.time() - start
518511start = time.time()
519512async_exec = db.async_executor().set_parallel_level(8 )
520513for i in range (10000 ):
521- vertex = db.new_vertex(" User" )
522- vertex.set(" userId" , i)
523- async_exec.create_record(vertex)
514+ async_exec.command(" sql" , " INSERT INTO User SET userId = :id" , id = i)
524515async_exec.wait_completion()
525516async_exec.close()
526517async_time = time.time() - start
0 commit comments