When walletnotify and blocknotify notifications are sent out?
Refers to Bitcoin Core 0.17:

WalletNotify

Will be executed at the time when a transaction gets added to the wallet. If your wallet is 100 blocks behind and in those 100 blocks you have 2 transaction in each block, the wallet notify script will be called twice per block (== 200 executions during the 100 block catch up).

Only valid blocks (valid transaction) will result in a wallet-notify call.

Will also be called when a mempool transactions (unconfirmed transaction) was added to the wallet (and therefore relevant to the wallet)

BlockNotify

Will be executed when a block gets connected to the active chain and before WalletNotify.

Consider taking a closer look at Bitcoin Cores ZMQ API that allows more efficient process interaction (wallet/block notify spawn a process on each call).