Giter Site home page Giter Site logo

enclosed-exceptions's People

Contributors

danburton avatar jcristovao avatar mitchellwrosen avatar snoyberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

enclosed-exceptions's Issues

tryAny catches StackOverflow

Steps to reproduce:

import           Control.Exception.Enclosed

main = do
  r <- tryAny (print $ foldl (+) 0 [1 .. 100000 :: Int])
  print r
$ ghci Main.hs +RTS -K1K
*Main> main 
Left stack overflow

tryDeep, catchDeep

These aren't needed as frequently, but I did find a use today and they are probably good for completeness.

  tryDeep :: (Exception e, NFData a, MonadBaseControl IO m)
          => m a
          -> m (Either e a)
  tryDeep m = try $ do
      x <- m
      liftBase $ evaluate $!! x

  catchDeep :: (Exception e, NFData a, MonadBaseControl IO m) => m a -> (e -> m a) -> m a
  catchDeep action onE = tryDeep action >>= either onE return

Unreliable test suites

This is a bug I introduced, just filing an issue since I may not have a moment to fix it immediately.

The test suite uses threadDelay to pass control between two difference threads of execution. This is not reliable, as threadDelay only gives a minimum delay time, not a maximum. When the system is under high load, this method can fail. We should instead use much more explicit control passing, such as via MVars.

Test suite hangs with ghc 8.4 (apparently due to hspec-2.5.0)

The last thing printed is:

Control.Exception.Enclosed
  catchAny
    catches exceptions thrown from the inside
    doesn't catch exceptions thrown from the outside
    doesn't catch exceptions lazily thrown in its pure result
  catchDeep
    catches exceptions thrown from the inside
    catches exceptions thrown from the outside
    catches exceptions lazily thrown in its pure result
  tryAny
    catches exceptions thrown from the inside
    doesn't catch exceptions thrown from the outside
    doesn't catch exceptions lazily thrown in its pure result

The next test is:

it "isn't fooled by BlockedIndefinitelyOnMVar" $ do

which suggests to me that something is going on with the "blocked indefinitely" behavior. Possibly a GHC regression?

Cleanup code doesn't get run after a `tryAny` of Snap's `httpServe`

This works fine.

        e <- try $ httpServe conf $ site :: IO (Either SomeException ())
        errorM "AdServer.Main.main" ("Got error while serving: " ++ show e)
        cleanup' cleanup

This doesn't run our cleanup code.

        e <- tryAny $ httpServe conf $ site
        errorM "AdServer.Main.main" ("Got error while serving: " ++ show e)
        cleanup' cleanup

I'm a bit flabbergasted as to why a lifted try would cause different behavior here, any ideas?

Repro:

Ctrl-C while blocking on a Snap server in GHCi

Good code runs our cleanup process, output like this:

^C
Shutting down...
Got error while serving: Right ()
Running Snap-provided cleanup function
Shutting down services
Killing the following services: Services {tableUpdate = Just ThreadId 574, stateServer = Just ThreadId 575, ekgServices = Nothing}
Removing logger handlers

Bad code shuts the Snap server down, but none of our secondary services get shut down and none of the logging associated with the cleanup runs. Output like this:

Listening on http://0.0.0.0:8000/
^CInterrupted.
Prelude>
Shutting down...

Prelude>

Only Snap's signal handling is getting run.

What did I do wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.