jboyens
2018-6-19 07:01:50

Subprocesses. In normal execution, I use the control proc to kill it, but if execution fails or stops in some way, I have cruft leftovers.


jboyens
2018-6-19 07:02:35

will-execute seems like the right direction, but… frankly it’s really hard to understand.


jboyens
2018-6-19 07:03:27

I want to say: “no matter what happens, ensure this proc gets run and murders this subprocess”


ma77rix
2018-6-19 07:24:02

it explains in the fold doc Iterates like for. Before iteration starts, the init-exprs are evaluated to produce initial accumulator values. At the start of each iteration, a location is generated for each accum-id, and the corresponding current accumulator value is placed into the location. The last expression in body must produce as many values as accum-ids, and those values become the current accumulator values. When iteration terminates, the results of the fold/for expression are the accumulator values. , I tried to find the source doe of for/fold on github, but didn’t find it..


pocmatos
2018-6-19 07:25:41

@jboyens not so familiar with subprocesses but what’s the issue with subprocess kill?


jboyens
2018-6-19 07:38:38

@pocmatos Works just fine, but it’s got to have a tie in to the interpreter in a way that means I’ll have a chance to kill the process if things go pear-shaped.


abmclin
2018-6-19 13:21:00

@jboyens I’m not 100% sure but I believe wills are only useful for items that can be directly analyzed and reasoned about by the garbage collector, in other words, objects existing within Racket’s virtual machine. Subprocesses won’t be able to benefit directly.

Subprocesses can communicate via ports so depending on what you’re running, you could wrap it in a script that performs an event loop where it listens for well-defined conditions in the foreign code you’re executing and sends messages to Racket-land via the subprocess’s stdout port. In Racket-land you’d set up something to listen for messages in-coming and take actions, make it synchronizable so Racket can do other useful work while your subprocess is doing its work.

You probably want to launch the subprocess in a separate Racket thread and also set up a timeout event to account the possibility the subprocess hangs.

Alternatively, you could program your subprocess to handle all possible exceptions and clean-up, leaving Racket out of it.


mflatt
2018-6-19 13:27:06

@jboyens Custodians are usually the right start; see current-subprocess-custodian-mode. If your Racket process is forcibly terminated externally (e.g., by kill -9), then there’s no solution. But as long as you get to run clean up, then custodian-shutdown-all is works as well as anything can – and since custodians are the internal mechanism for forced termination, they chain well.


shu--hung
2018-6-19 16:26:32

@ma77rix: I would guess it is a design decision that makes the body clause easy to understand, is consistent with other for forms (like for/hash) and ease the implementation complexity


shu--hung
2018-6-19 16:26:46

The implementation is here, but it’s rather low level https://github.com/racket/racket/blob/master/racket/collects/racket/private/for.rkt


shu--hung
2018-6-19 16:30:41

For for/fold, because each accumulator would obtain a new value in each iteration, having the for body evaluates to multiple values seems reasonable


ma77rix
2018-6-19 17:27:00

:+1: make sense


greg
2018-6-19 23:40:46

Do package suggestions work for anyone? e.g. I don’t have @samth’s abnf package installed: https://pkgs.racket-lang.org/package/abnf In DrRacket 6.7 or 6.10 I do #lang racket (require scribble/abnf) It errors (as expected), but the message says “no packages suggestions are available” (not expected). Below it is an “update packages” link. I click it. Some window pops up and disappears too fast for me to see what it is. I try again, same result.

Or, equivalently (I think): #lang racket (require pkg/lib) (pkg-catalog-suggestions-for-module 'scribble/abnf) returns '().

Does any of this work for anyone else?


greg
2018-6-19 23:53:34

[ Why I ask: I could have sworn this used to work. In fact, I made racket-mode install an error handler that tries to make suggestions, very similar to what DrRacket does. I was about to point this out to someone on #racket IRC, and realized I hadn’t tried it in a very long while, so I tried before I spoke. Which turned out to be wise. :slightly_smiling_face: ]


mflatt
2018-6-20 00:00:09

The “Update Catalog” button seems to fail if you don’t have a local catalog already. If you select “Package Manager…” and then then “Available from Catalog” tab, the “Update” button in the dialog that appears will successfully create the catalog. I’ll look more into why the “Update Catalog” button doesn’t work.


mflatt
2018-6-20 00:15:33

The “Update Catalog” button doesn’t work because the local database’s set of source catalogs is not set to be the currently configured catalogs. If there’s not a local database already, that counts as configured to 0 catalogs, and “Update Catalog” quickly updates 0 catalogs.


mflatt
2018-6-20 00:17:27

The “Available from Catalog” panel notices the mismatch (database vs. current catalogs configuration) and asks you whether to reset the database. Maybe the “Update” button should just set the database to the current catalogs configuration.


jboyens
2018-6-20 06:25:31

Working with macros and I’m running into this: http://pasterack.org/pastes/4964 with a simple macro


jboyens
2018-6-20 06:25:52

It seems to work fine, but I’m getting an error that I can’t quite understand.


jboyens
2018-6-20 06:26:32

The macro expansion ends up with ((displayln (current-session)) and I think that’s the location of the error