Masturbation during miscarriage

I had a miscarriage last week, and now I’ve been horny and been wanting some from my bf but Ik it’s best to wait to not get a infection. But is it safe to at least masturbate??