Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/src/tcf/channel/ChannelTCP.py15
-rw-r--r--python/src/tcf/tests/BasicTests.py3
-rw-r--r--python/src/tcf/util/task.py14
3 files changed, 18 insertions, 14 deletions
diff --git a/python/src/tcf/channel/ChannelTCP.py b/python/src/tcf/channel/ChannelTCP.py
index ae020237b..7126e9554 100644
--- a/python/src/tcf/channel/ChannelTCP.py
+++ b/python/src/tcf/channel/ChannelTCP.py
@@ -23,12 +23,15 @@ class ChannelTCP(StreamChannel):
channel = self
class CreateSocket(object):
def __call__(self):
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- sock.connect((host, port))
- sock.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1)
- sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
- channel.socket = sock
- channel._onSocketConnected(None)
+ try:
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.connect((host, port))
+ sock.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1)
+ sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
+ channel.socket = sock
+ channel._onSocketConnected(None)
+ except Exception as x:
+ channel._onSocketConnected(x)
protocol.invokeLater(CreateSocket())
def _onSocketConnected(self, x):
diff --git a/python/src/tcf/tests/BasicTests.py b/python/src/tcf/tests/BasicTests.py
index 7e3bbb9cf..24b92939c 100644
--- a/python/src/tcf/tests/BasicTests.py
+++ b/python/src/tcf/tests/BasicTests.py
@@ -9,7 +9,7 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import sys, time, threading
+import sys, time, threading, atexit
import tcf
from tcf import protocol, channel, errors
from tcf.util import sync
@@ -28,6 +28,7 @@ _memory = []
def test():
protocol.startEventQueue()
+ atexit.register(protocol.getEventQueue().shutdown)
#testTimer()
try:
c = tcf.connect("TCP:127.0.0.1:1534")
diff --git a/python/src/tcf/util/task.py b/python/src/tcf/util/task.py
index 77f5bab36..a31d49a6e 100644
--- a/python/src/tcf/util/task.py
+++ b/python/src/tcf/util/task.py
@@ -93,10 +93,10 @@ class Task(object):
def error(self, error):
"""
- Set a __error and notify all threads waiting for the task to complete.
+ Set a error and notify all threads waiting for the task to complete.
The method is supposed to be called in response to executing of run() method of this task.
- @param __error - computation __error.
+ @param error - computation error.
"""
assert protocol.isDispatchThread()
assert error
@@ -127,7 +127,7 @@ class Task(object):
retrieves its result.
@return the computed result
- @throws CancellationException if the computation was __canceled
+ @throws CancellationException if the computation was canceled
@throws ExecutionException if the computation threw an
exception
@throws InterruptedException if the current thread was interrupted
@@ -145,10 +145,10 @@ class Task(object):
def isCancelled(self):
"""
- Returns <tt>true</tt> if this task was __canceled before it completed
+ Returns <tt>true</tt> if this task was canceled before it completed
normally.
- @return <tt>true</tt> if task was __canceled before it completed
+ @return <tt>true</tt> if task was canceled before it completed
"""
with self._lock:
return self.__canceled
@@ -168,8 +168,8 @@ class Task(object):
def getError(self):
"""
- Return task execution __error if any.
- @return Throwable object or None
+ Return task execution error if any.
+ @return Exception object or None
"""
return self.__error

Back to the top