Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Guard against different return values for remove_pusher.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Jul 29, 2020
1 parent a53e016 commit 82db25a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/7981.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Convert various parts of the codebase to async/await.
7 changes: 6 additions & 1 deletion synapse/push/httppusher.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import inspect
import logging

from prometheus_client import Counter
Expand Down Expand Up @@ -296,7 +297,11 @@ async def _process_one(self, push_action):
)
else:
logger.info("Pushkey %s was rejected: removing", pk)
await self.hs.remove_pusher(self.app_id, pk, self.user_id)
# remove_pusher might return an awaitable (for the main
# process) or None (for a worker process).
result = self.hs.remove_pusher(self.app_id, pk, self.user_id)
if inspect.isawaitable(result):
await result
return True

async def _build_notification_dict(self, event, tweaks, badge):
Expand Down

0 comments on commit 82db25a

Please sign in to comment.