Method: SQLite::API.busy_handler
- Defined in:
- ext/sqlite-api.c
.busy_handler(db, handler) ⇒ nil
Installs a callback to be invoked whenever a request cannot be honored because a database is busy. The handler should take two parameters: a string naming the resource that was being accessed, and an integer indicating how many times the current request has failed due to the resource being busy.
If the handler returns false, the operation will be aborted, with a SQLite::BusyException being raised. Otherwise, SQLite will attempt to access the resource again.
See #busy_timeout for an easier way to manage the common case.
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 |
# File 'ext/sqlite-api.c', line 566 static VALUE static_api_busy_handler( VALUE module, VALUE db, VALUE handler ) { sqlite *handle; GetDB( handle, db ); if( handler == Qnil ) { sqlite_busy_handler( handle, NULL, NULL ); } else { if( !rb_obj_is_kind_of( handler, rb_cProc ) ) { rb_raise( rb_eArgError, "handler must be a proc" ); } sqlite_busy_handler( handle, static_busy_handler, (void*)handler ); } return Qnil; } |