You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by al...@apache.org on 2020/09/08 15:22:51 UTC

[skywalking-python] branch fix_reconnect created (now c223029)

This is an automated email from the ASF dual-hosted git repository.

alonelaval pushed a change to branch fix_reconnect
in repository https://gitbox.apache.org/repos/asf/skywalking-python.git.


      at c223029  fix cannot reconnect

This branch includes the following new commits:

     new c223029  fix cannot reconnect

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[skywalking-python] 01/01: fix cannot reconnect

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

alonelaval pushed a commit to branch fix_reconnect
in repository https://gitbox.apache.org/repos/asf/skywalking-python.git

commit c2230297954249beac879eaa7656118acd2d3b4b
Author: huawei <al...@gmail.com>
AuthorDate: Tue Sep 8 23:22:22 2020 +0800

    fix cannot reconnect
---
 skywalking/agent/__init__.py | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/skywalking/agent/__init__.py b/skywalking/agent/__init__.py
index 8ed9759..a57c47e 100644
--- a/skywalking/agent/__init__.py
+++ b/skywalking/agent/__init__.py
@@ -32,18 +32,26 @@ logger = logging.getLogger(__name__)
 def __heartbeat():
     while not __finished.is_set():
         if connected():
-            __protocol.heartbeat()
-
-        __finished.wait(30 if connected() else 3)
+            try:
+                __protocol.heartbeat()
+                __finished.wait(3)
+            except Exception as e:
+                pass
+        else:
+            connect()
+            __finished.wait(30)
 
 
 def __report():
     while not __finished.is_set():
         if connected():
-            __protocol.report(__queue)
-            break
+            try:
+                __protocol.report(__queue)
+            except Exception as e:
+                pass
         else:
-            __finished.wait(1)
+            connect()
+            __finished.wait(30)
 
 
 __heartbeat_thread = Thread(name='HeartbeatThread', target=__heartbeat, daemon=True)
@@ -55,6 +63,11 @@ __started = False
 
 
 def __init():
+    connect()
+    plugins.install()
+
+
+def connect():
     global __protocol
     if config.protocol == 'grpc':
         from skywalking.agent.protocol.grpc import GrpcProtocol
@@ -63,8 +76,6 @@ def __init():
         from skywalking.agent.protocol.http import HttpProtocol
         __protocol = HttpProtocol()
 
-    plugins.install()
-
 
 def start():
     global __started