Skip to content

Commit

Permalink
Replace time.clock() with process_time for later versions of Python
Browse files Browse the repository at this point in the history
  • Loading branch information
icraggs committed Oct 2, 2020
1 parent 61b0490 commit 2873885
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 8 additions & 2 deletions interoperability/mqtt/brokers/V311/Brokers.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ def cleanSession(self, aClientid):

def connect(self, aClient):
aClient.connected = True
aClient.timestamp = time.clock()
try:
aClient.timestamp = time.clock() # time.clock is deprecated
except:
aClient.timestamp = time.process_time()
self.__clients[aClient.id] = aClient
if aClient.cleansession:
self.cleanSession(aClient.id)
Expand All @@ -80,7 +83,10 @@ def disconnect(self, aClientid):
del self.__clients[aClientid]
else:
logger.info("[MQTT-3.1.2-4] broker must store the session data for client %s", aClientid)
self.__clients[aClientid].timestamp = time.clock()
try:
self.__clients[aClientid].timestamp = time.clock() # time.clock is deprecated
except:
self.__clients[aClientid].timestamp = time.process_time()
self.__clients[aClientid].connected = False
logger.info("[MQTT-3.1.2-10] will message is deleted after use or disconnect, for client %s", aClientid)
logger.info("[MQTT-3.14.4-3] on receipt of disconnect, will message is deleted")
Expand Down
5 changes: 4 additions & 1 deletion interoperability/mqtt/brokers/V5/Brokers.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ def cleanSession(self, aClientid):

def connect(self, aClient, clean=False):
aClient.connected = True
#aClient.timestamp = time.clock()
try:
aClient.timestamp = time.clock() # time.clock is deprecated
except:
aClient.timestamp = time.process_time()
self.__clients[aClient.id] = aClient
if clean:
self.cleanSession(aClient.id)
Expand Down

0 comments on commit 2873885

Please sign in to comment.