On Thu, Feb 16, 2017 at 2:33 PM, Dan Liebgold <[email protected]>
wrote:
> Hi -
>
> I have a few racket process running on Windows that need to each ensure
> the same directory structure exists. I have code like this:
>
> (unless (directory-exists? dir)
> (make-directory dir))
>
> Well, since they're running in parallel occasionally they race and try to
> make the directory after another has done so, resulting in an exception.
>
> How can I rewrite this so that it either eats the exception or is atomic?
>
> Thanks,
> Dan
>
Will this do?
(with-handlers ((exn:fail? (lambda (e) #t)))
(make-directory "bar"))
It doesn't do the 'directory-exists?' check and it will eat the exceptions.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.