@Jimm - no probs, just wanted to explain why Count Pages (and Extract ISBN) work that way. I can 100% understand and sympathise with why you wanted to try to avoid the prompt - we would all love that. However as you may know from elsewhere database locking approaches and strategies are a headache every concurrent application faces. I can totally understand why Kovid took the simplest approach possible, which unfortunately means an interactive prompt. And in the case of your plugin for a user doing count pages, it will now mean two of them.
The alternatives just become increasingly more complex everywhere. Every time you do an update to the database you have to be prepared that it could "fail" because (a) the user may have merged/deleted the book or otherwise changed it so it no longer represents what it "was", (b) the user may have changed the same data you are now wanting to update - so you have to decide which one "wins" either by overwriting or by rejecting the change (which has huge repercussions). And then of course (c) you have all the GUI complications, books potentially being added/removed/updated in the background means what you see on screen does not reflect "current reality" which is important when you try to edit or perform operations. Ugh.
Which is why I shall be interested to see what approach Kovid has in mind as part of his database back-end rewrite. If he is going to allow multiple instances of calibre to connect to the same database... fun, fun, fun...