Maybe this isn't mandatory, but it's definitely something London promised.
London's candidate file, the document that outlines arrangements for the 2012 games, states that "no important national or international events will take place in London or the vicinity of any of the other competition sites during the games or in the week before or following the games".Actually, there's no way New York could have made such a promise. New York could not have imposed such a "blackout" on surrounding areas nor do I think baseball would have agreed to no games in New York for four weeks during the summer.
The London Olympics are scheduled to run from July 25 to August 12, which means the affected period would stretch from July 18 to August 19, and covers events in London's boroughs, local authorities outside the capital's hosting venues and the devolved administrations of Wales, Northern Ireland and Scotland, all of which have agreed to honour the commitment.