Skip to content

Commit cd68b02

Browse files
committed
Avoid pydetach and fork in haskell
1 parent 015bd11 commit cd68b02

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Graphics/Matplotlib.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,17 @@ where
7070
import Data.List
7171
import Data.Aeson
7272
import Graphics.Matplotlib.Internal
73+
import Control.Concurrent(forkIO)
7374

7475
-- * Running a plot
7576

7677
-- | Show a plot, blocks until the figure is closed
77-
onscreen :: Matplotlib -> IO (Either String String)
78-
onscreen m = withMplot m (\s -> python $ pyIncludes "" ++ s ++ pyDetach ++ pyOnscreen)
78+
onscreen :: Matplotlib -> IO ()
79+
onscreen m = (forkIO $ (withMplot m (\s -> python $ pyIncludes "" ++ s ++ pyOnscreen) >> return ())) >> return ()
7980

8081
-- | Print the python code that would be executed
8182
code :: Matplotlib -> IO String
82-
code m = withMplot m (\s -> return $ unlines $ pyIncludes (pyBackend "agg") ++ s ++ pyDetach ++ pyOnscreen)
83+
code m = withMplot m (\s -> return $ unlines $ pyIncludes (pyBackend "agg") ++ s ++ pyOnscreen)
8384

8485
-- | Save to a file
8586
file :: [Char] -> Matplotlib -> IO (Either String String)

src/Graphics/Matplotlib/Internal.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ resolvePending m = m { mpCommands =
6464

6565
-- | The io action is given a list of python commands to execute (note that
6666
-- these are commands in the sense of lines of python code; each inidivudal line
67-
-- may not be parseable on its own
67+
-- may not be parseable on its own)
6868
withMplot :: Matplotlib -> ([String] -> IO a) -> IO a
6969
withMplot m f = preload cs []
7070
where

0 commit comments

Comments
 (0)