Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraleherbau2011-05-27 07:47:58 -0400
committeraleherbau2011-05-27 07:47:58 -0400
commit60def20cd9db7c76d7450c58658021e5cc0ba08e (patch)
treeb388bb12fedc4a27edadce8f2f3a12348561487c
parent009543ef37841c5f1f7ae4dcb849573c3d3ea7a4 (diff)
downloadorg.eclipse.tcf-60def20cd9db7c76d7450c58658021e5cc0ba08e.tar.gz
org.eclipse.tcf-60def20cd9db7c76d7450c58658021e5cc0ba08e.tar.xz
org.eclipse.tcf-60def20cd9db7c76d7450c58658021e5cc0ba08e.zip
TCF Python: Fixed timer queue sorting, time units
-rw-r--r--python/src/tcf/channel/AbstractChannel.py2
-rw-r--r--python/src/tcf/errors.py2
-rw-r--r--python/src/tcf/peer.py8
-rw-r--r--python/src/tcf/protocol.py11
-rw-r--r--python/src/tcf/shell.py2
-rw-r--r--python/src/tcf/util/logging.py2
6 files changed, 15 insertions, 12 deletions
diff --git a/python/src/tcf/channel/AbstractChannel.py b/python/src/tcf/channel/AbstractChannel.py
index d8991e383..39ca084a8 100644
--- a/python/src/tcf/channel/AbstractChannel.py
+++ b/python/src/tcf/channel/AbstractChannel.py
@@ -681,7 +681,7 @@ class AbstractChannel(object):
if self.local_congestion_cnt < 8: return
self.local_congestion_cnt = 0
if self.state != STATE_OPEN: return
- timeVal = int(time.time())
+ timeVal = int(time.time() * 1000)
if timeVal - self.local_congestion_time < 500: return
assert protocol.isDispatchThread()
level = protocol.getCongestionLevel()
diff --git a/python/src/tcf/errors.py b/python/src/tcf/errors.py
index bac4b5be3..79c2706a9 100644
--- a/python/src/tcf/errors.py
+++ b/python/src/tcf/errors.py
@@ -78,7 +78,7 @@ class ErrorReport(Exception):
if type(attrs) is types.IntType:
attrs = {
ERROR_CODE : attrs,
- ERROR_TIME : int(time.time()),
+ ERROR_TIME : int(time.time() * 1000),
ERROR_FORMAT : msg,
ERROR_SEVERITY : SEVERITY_ERROR
}
diff --git a/python/src/tcf/peer.py b/python/src/tcf/peer.py
index 15596db03..48269a385 100644
--- a/python/src/tcf/peer.py
+++ b/python/src/tcf/peer.py
@@ -195,7 +195,7 @@ class AbstractPeer(TransientPeer):
if attrs.get(key) != self.rw_attrs.get(key):
equ = False
break
- timeVal = int(time.time())
+ timeVal = int(time.time() * 1000)
if not equ:
self.rw_attrs.clear()
self.rw_attrs.update(attrs)
@@ -234,7 +234,7 @@ class AbstractPeer(TransientPeer):
protocol.sendEvent(locator.NAME, "peerAdded", json.dumps(args))
except IOError as x:
protocol.log("Locator: failed to send 'peerAdded' event", x)
- self.last_heart_beat_time = int(time.time())
+ self.last_heart_beat_time = int(time.time() * 1000)
def sendPeerRemovedEvent(self):
for l in protocol.getLocator().getListeners():
@@ -264,11 +264,11 @@ class RemotePeer(AbstractPeer):
def __init__(self, attrs):
super(RemotePeer, self).__init__(attrs)
- self.last_update_time = int(time.time())
+ self.last_update_time = int(time.time() * 1000)
def updateAttributes(self, attrs):
super(RemotePeer, self).updateAttributes(attrs)
- self.last_update_time = int(time.time())
+ self.last_update_time = int(time.time() * 1000)
def getLastUpdateTime(self):
return self.last_update_time
diff --git a/python/src/tcf/protocol.py b/python/src/tcf/protocol.py
index 96b91d18c..b6644cd8d 100644
--- a/python/src/tcf/protocol.py
+++ b/python/src/tcf/protocol.py
@@ -86,7 +86,8 @@ def invokeLaterWithDelay(delay, callable, *args, **kwargs):
_event_queue.invokeLater(callable, *args, **kwargs)
else:
with _timer_queue_lock:
- _timer_queue.append(Timer(time.time() + delay /1000., callable, *args, **kwargs))
+ _timer_queue.append(Timer(time.time() + delay/1000., callable, *args, **kwargs))
+ _timer_queue.sort()
_timer_queue_lock.notify()
def invokeAndWait(callable, *args, **kwargs):
@@ -98,7 +99,7 @@ def invokeAndWait(callable, *args, **kwargs):
This method can be invoked from any thread.
- @param runnable the callable to be executed on dispatch thread.
+ @param callable the callable to be executed on dispatch thread.
"""
if _event_queue.isDispatchThread():
return callable(*args, **kwargs)
@@ -183,9 +184,9 @@ class ChannelOpenListener(object):
The interface allows a client to get pointers to channel objects
that were opened by somebody else. If a client open a channel itself, it already has
- the pointer and does not need Protocol.ChannelOpenListener. If a channel is created,
+ the pointer and does not need protocol.ChannelOpenListener. If a channel is created,
for example, by remote peer connecting to the client, the only way to get the pointer
- is Protocol.ChannelOpenListener.
+ is protocol.ChannelOpenListener.
"""
def onChannelOpen(self, channel):
pass
@@ -242,7 +243,7 @@ class CongestionMonitor(object):
Note: Local (in-bound traffic) congestion is detected by framework and reported to
remote peer without client needed to be involved. Only clients willing to provide
additional data about local congestion should implement CongestionMonitor and
- register it using Protocol.addCongestionMonitor().
+ register it using protocol.addCongestionMonitor().
"""
def getCongestionLevel(self):
"""
diff --git a/python/src/tcf/shell.py b/python/src/tcf/shell.py
index bf29f0ec0..aa3958603 100644
--- a/python/src/tcf/shell.py
+++ b/python/src/tcf/shell.py
@@ -17,6 +17,7 @@ Usage:
python tcf/shell.py
Commands:
+ peers - Print discovered peers
connect(params) - Connect to TCF peer, params = "<protocol>:<host>:<port>"
cmd.<service>.<command<(args)
- Send command to remote service and return result
@@ -34,6 +35,7 @@ from tcf.util import sync, event
from tcf import protocol, channel
class print_peers:
+ "Print list of discovered peers"
def __call__(self):
return tcf.peers()
def __repr__(self):
diff --git a/python/src/tcf/util/logging.py b/python/src/tcf/util/logging.py
index 7ac2c22e3..afe3037fc 100644
--- a/python/src/tcf/util/logging.py
+++ b/python/src/tcf/util/logging.py
@@ -29,7 +29,7 @@ def getDebugTime():
traceBuilder = cStringIO.StringIO()
# Record the time
- tm = int(time.time())
+ tm = int(time.time() * 1000)
seconds = (tm / 1000) % 1000
if seconds < 100: traceBuilder.write('0')
if seconds < 10: traceBuilder.write('0')

Back to the top