show error when sqlite crashes worker thread
Better than "blocked indefinitely in MVar"..
This commit is contained in:
parent
99a1287f4f
commit
ea76d04e15
1 changed files with 3 additions and 1 deletions
|
@ -16,6 +16,7 @@ module Database.Handle (
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Utility.Exception
|
import Utility.Exception
|
||||||
|
import Messages
|
||||||
|
|
||||||
import Database.Persist.Sqlite (runSqlite)
|
import Database.Persist.Sqlite (runSqlite)
|
||||||
import Database.Esqueleto hiding (Key)
|
import Database.Esqueleto hiding (Key)
|
||||||
|
@ -41,8 +42,9 @@ openDb db = do
|
||||||
return $ DbHandle worker jobs t
|
return $ DbHandle worker jobs t
|
||||||
|
|
||||||
workerThread :: T.Text -> MVar Job -> IO ()
|
workerThread :: T.Text -> MVar Job -> IO ()
|
||||||
workerThread db jobs = go
|
workerThread db jobs = catchNonAsync go showerr
|
||||||
where
|
where
|
||||||
|
showerr e = liftIO $ warningIO $ "sqlite worker thread crashed: " ++ show e
|
||||||
go = do
|
go = do
|
||||||
r <- runSqlite db transaction
|
r <- runSqlite db transaction
|
||||||
case r of
|
case r of
|
||||||
|
|
Loading…
Add table
Reference in a new issue