abarbu / matplotlib-haskell

Haskell bindings for Python's Matplotlib
Other
85 stars 12 forks source link

`onscreen` not working for me #2

Closed fhaust closed 5 years ago

fhaust commented 7 years ago

The onscreen way of displaying graphs does not work for me. Neither by calling it interactively from ghci nor from a compiled program. The (Haskell) program just stops apparently waiting for the python subprocess to end.

If edit the emitted script in the tmp folder manually and remove these lines:

pid = os.fork()
if(pid != 0):
  exit(0)
plot.draw()

I can call it manually but with them it just ends after a while.

fhaust commented 7 years ago

Just noticed that the related pyDetach function is documented as "does not work reliable". Maybe create the process in a Haskell thread and handle forking there?

abarbu commented 7 years ago

Yeah.. Guess we're going to have to go the process route! I'll get to it later in the week. I wonder why they have an API call that's not reliable?

abarbu commented 7 years ago

Things should work now. There's a race condition in how files a read. I changed python to not detach and to fork in Haskell instead. Let me know if that fixes things.

LukaHorvat commented 7 years ago

It works for me.

fhaust commented 7 years ago

Hmm ... does not work for me. But honestly I am not sure if I got the latest version. Will check that out tomorrow maybe.

abarbu commented 7 years ago

That could be. The stackage nightly and lts haven't been regenerated yet since I pushed this. should be another day for one and a week or os for the other. Let me know.

fhaust commented 7 years ago

I actually pointed stack at the github repository. But as I said I am not sure that worked.

jchia commented 7 years ago

On 17425a831b254b4ef2cafdfe2edabf832058882d, I had to threadDelay 1 after onscreen for the plot to appear. If main is just onscreen ... without the threadDelay 1, the program exits without showing the plot.

abarbu commented 7 years ago

Ok. I'll make a more permanent solution with a lockfile to eliminate these race conditions when I get some free time this weekend.

abarbu commented 5 years ago

Hi folks, I'm going to close this as it's been a long time. Hopefully the ecosystem is more stable now and these problems have gone away. Feel free to reopen.

shlok commented 3 years ago

On 17425a8, I had to threadDelay 1 after onscreen for the plot to appear. If main is just onscreen ... without the threadDelay 1, the program exits without showing the plot.

This solution worked for me (however, I had to increase the delay to 10).

vlyr commented 1 year ago

On 17425a8, I had to threadDelay 1 after onscreen for the plot to appear. If main is just onscreen ... without the threadDelay 1, the program exits without showing the plot.

Also worked for me. I did have to set the delay to 3000 though.