Skip to content

Commit

Permalink
added timeout error message
Browse files Browse the repository at this point in the history
  • Loading branch information
gretzke committed Dec 9, 2019
1 parent a092363 commit 17ead7b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions plug_py/plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# websockets
import websockets
import asyncio
from socket import socket, AF_INET, SOCK_DGRAM, SOL_SOCKET, SO_REUSEADDR
from socket import socket, AF_INET, SOCK_DGRAM, SOL_SOCKET, SO_REUSEADDR, timeout

# utility libraries
import operator
Expand Down Expand Up @@ -347,9 +347,13 @@ def run(self):
asyncio.set_event_loop(self.loop)
self.loop.run_until_complete(self.wsConnection())
else:
window.updateInfo('No smart socket found')
window.updateInfo('Error while connecting to smart socket')
window.updateInfoCenter('')
except timeout:
window.updateInfo('No smart socket found')
window.updateInfoCenter('')
except:
window.updateInfo('Error in connecting to smart socket')
window.updateInfo('Error while connecting to smart socket')
window.updateInfoCenter('')

# disconnect from websocket and display message to user
Expand Down Expand Up @@ -545,7 +549,7 @@ async def initialized_P(self):
if (transactionReceipt.status == 1):
window.updateInfoCenter(
'Successfully initialized Payment Channel')

QThread().sleep(0.5)
await self.websocket.send(json.dumps(
{"id": self.paymentState.value, "price": self.pricePerSecond, 'nonce': self.nonce, 'maxValue': self.maxValue}))
self.paymentState = State.initialized_S
Expand All @@ -559,7 +563,6 @@ async def initialized_S(self):
self.transactionCounter = 0
self.transactionValue = 0
window.updateInfo('Payment Channel active')
QThread().sleep(0.5)
self.paymentState = State.active_P

async def active_P(self):
Expand Down

0 comments on commit 17ead7b

Please sign in to comment.