I just did battle with sewer gnats last month. I got them from the RV park I live in, and I'm sure other people here have them also. Do you really want something born and raised in sewage flying around in your living space? I do not leave the sewage valves open - never have - and only dump once a week.
I disconnected everything and cleaned all the hoses and connectors, then I cleaned them a second time with bleach. I removed all the washers and rubber seals and cleaned them the same way. I poured a gallon of bleach in the empty black tank and a gallon in the empty grey tank, followed by extremely hot water until both tanks were 3/4 full. Then I went for a drive to get that hot bleach water sloshing around in the tanks.
When I returned I went to the park's sewer hookup and sprayed half a can of Raid Flying Insect Killer down the pipe, hitting the sides so they were completely soaked with it. I gave that about 1/2 hour to do it's job. Then I hooked everything back up, starting with the sewer donut. I used my sewer hose support only on for the last 4 feet of hose, forcing a droop in the hose, which will have the same effect as a p-trap under a sink, in that it will stay filled with water, preventing any flies from coming up.
Only after doing all that did I open the valves and drain my tanks. I have seen no gnats since and am very thankful!
I have had them before and the only thing that really worked was cold weather. I'm in Florida and am not waiting for cold weather.
If you Google "sewer gnats" you'll learn all the juicy facts.