64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
+
-
-
-
+
+
-
-
-
-
+
+
+
|
(debug:print 4 "INFO: dbpath=" dbpath)
(sqlite3:set-busy-handler! db handler)
(if (not dbexists)
(db:initialize db))
(db:set-sync db)
db))
;; keeping it around for debugging purposes only
(define (open-run-close-no-exception-handling proc idb . params)
(let* ((db (if idb idb (open-db)))
(res #f))
(db:set-sync db)
(set! res (apply proc db params))
(if (not idb)(sqlite3:finalize! db))
res))
(define (open-run-close-exception-handling proc idb . params)
(let ((runner (lambda ()
(let* ((db (if idb idb (open-db)))
(res #f))
(let* ((db (if idb idb (open-db)))
(res #f))
(db:set-sync db)
(set! res (apply proc db params))
(if (not idb)(sqlite3:finalize! db))
res))))
(set! res (apply proc db params))
(if (not idb)(sqlite3:finalize! db))
res))))
(handle-exceptions
exn
(begin
(debug:print 0 "EXCEPTION: database probably overloaded?")
(debug:print 0 " " exn)
(print-call-chain)
(thread-sleep! (random 120))
|