Skip to content

Commit

Permalink
Use RuntimeError for unsupported feature rather than warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreF committed Jan 10, 2024
1 parent f027612 commit 524df4a
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions src/paho/mqtt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import urllib.parse
import urllib.request
import uuid
import warnings

from .matcher import MQTTMatcher
from .properties import Properties
Expand Down Expand Up @@ -665,11 +664,7 @@ def keepalive(self, value: int) -> None:
if self._sock is not None:
# The issue here is that the previous value of keepalive matter to possibly
# sent ping packet.
warnings.warn(
"updating keepalive on established connection is not supported",
stacklevel=2,
)
self._sock.settimeout(value)
raise RuntimeError("updating keepalive on established connection is not supported")

if value < 0:
raise ValueError("Keepalive must be >=0.")
Expand Down Expand Up @@ -759,10 +754,7 @@ def max_inflight_messages(self, value: int) -> None:
if self._sock is not None:
# Not tested. Some doubt that everything is okay when max_inflight change between 0
# and > 0 value because _update_inflight is skipped when _max_inflight_messages == 0
warnings.warn(
"updating max_inflight_messages on established connection is not supported",
stacklevel=2,
)
raise RuntimeError("updating max_inflight_messages on established connection is not supported")

if value < 0:
raise ValueError("Invalid inflight.")
Expand All @@ -779,10 +771,7 @@ def max_queued_messages(self, value: int) -> None:
"Update max_queued_messages. It's behavior is undefined if the connection is already open"
if self._sock is not None:
# Not tested.
warnings.warn(
"updating max_queued_messages on established connection is not supported",
stacklevel=2,
)
raise RuntimeError("updating max_queued_messages on established connection is not supported")

if value < 0:
raise ValueError("Invalid queue size.")
Expand Down

0 comments on commit 524df4a

Please sign in to comment.