This was to have been a celebratory month, a time when the two major political parties nominate their presidential candidates amid pageantry and expressions of optimism and unity. Instead, July has begun with violence of the worst kind, and with shock and horror and an escalation of racial tensions. Summer 2016 threatens to be long and divisive.

The horrific killing Thursday night of five police officers in Dallas, and the earlier killings of individual African Americans by officers in Baton Rouge and Falcon Heights, Minn., have left families grieving, communities on edge and the country numbed by the meaning of it all.

In its totality, the week of gunfire and fallen bodies and videos too graphic to absorb but impossible not to watch has produced a whiplash of emotions and reactions. Whether they add up to anything constructive or simply add to the feeling of a country that is fractured and breaking apart is another matter — but one of genuine urgency.

This summer of shocks has left everyone with a sense of insecurity, whether from threats of foreign terrorism visited on U.S. shores to the randomness of what happened in Louisiana and Minnesota to the chilling nature of what seems to have been a planned execution of law enforcement officers in Dallas. What safe space now exists? Not in a gay nightclub in Orlando or the streets of major cities or quiet suburbs or at a demonstration where police protected and mingled with the public before the gunfire shattered everything.

The country has been through violent summers before. The summer of 1965 saw terrible riots in the Watts section of Los Angeles. The summer of 1967 brought riots to the streets of Newark and Detroit. The spring and summer of 1968 saw assassinations of Martin Luther King Jr. and Robert Kennedy and then brutal conflict at the Democratic National Convention in Chicago when police beat and tear-gassed anti-Vietnam War demonstrators in the parks and streets.

In this decade, the killings of black men by white police officers in Ferguson, Mo., and New York City and elsewhere have widened the gulf between minority communities and local law enforcement, giving rise to the Black Lives Matter movement and a backlash against it. The deaths of five Dallas officers Thursday at the hand of a shooter who reportedly told a police negotiator that he wanted to “kill white people, especially white officers,” brought a plea from Dallas Police Chief David Brown for understanding and support for those who risk their lives to protect others’ safety and freedoms.

The killings this week come at a time not only of racial tensions but also of deep political divisions. Those divisions have been growing wider over the past dozen or more years, almost tribal in nature, with each side increasingly suspicious of the other. Those divisions reflect broader reactions to cultural and demographic changes that are reshaping the country.

A year after the 1967 riots, the Kerner Commission, appointed by then-President Lyndon B. Johnson, returned with a report whose most remembered words were: “Our nation is moving toward two societies, one black, one white — separate but unequal.” What would a similar commission say about the country today, nearly a half-century later? Perhaps only to add that the country is also divided red and blue.

The current presidential campaign has worsened the political divisions, unleashing anger and rhetoric and hostility across the political divide. The candidacy of Donald Trump has contributed to this, with his attacks on Mexicans and Muslims. But his support is in part an expression of frustration on the part of Americans who also feel neglected and disrespected by the political classes, inevitably causing a widening of the gap.

Trump’s rallies have sparked sporadic violence, inside and outside the arenas where he has appeared. His words have encouraged supporters to go after some of the demonstrators. In turn, protests against his candidacy have turned violent toward some of his supporters. Americans are saying things about one another and to one another that long have been considered out of bounds.

President Obama gave remarks on the Dallas shooting that has left at least five police officers dead, while at a summit in Warsaw, Poland, on July 8. (Reuters)

In a few days, Republicans will begin to gather in Cleveland for preliminary meetings ahead of their national convention. That convention begins July 18, to be followed by the Democratic National Convention in Philadelphia the following week. Both cities are braced for trouble, especially Cleveland, given what has happened at the scene of Trump events elsewhere. Security will be tighter than ever. Some of those planning to attend have been going through riot training to protect themselves in the event that demonstrations turn violent. That is one measure of the state of the country right now.

Another measure is that in the course of 12 or so hours, President Obama, traveling in Poland, was twice forced to make comments about events back home. The first, moments after he landed Thursday, addressed the killings in Louisiana and Minnesota.

“All of us as Americans should be troubled by these shootings, because these are not isolated incidents,” he said. “They’re symptomatic of a broader set of racial disparities that exist in our criminal justice system.”

Then early Friday, he addressed the overnight horrors in Dallas, calling what happened, “a vicious, calculated and despicable attack on law enforcement.” He added, “I speak for every single American when I say that we are horrified over these events, and that we stand united with the people and the police department in Dallas.”

These are not incompatible thoughts by any means, but they speak to the challenge of the moment of dealing with the underlying problems that the week’s violence highlights. For politicians it is a minefield.

Some perspective is necessary. This is not the summer of 1967 or 1968. But the political climate and the racial climate have now become commingled in potentially toxic ways that will test political leaders and citizens alike.

Perhaps the rest of July will be what it was supposed to be, a time in which both parties and their leaders seek to unite and reach out. But random events threaten to disrupt and divide, and politicians will be pressed not to further inflame the moment by their own actions. Who can say whether they will rise to meet the test?