You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2020/12/30 04:22:27 UTC

[GitHub] [skywalking-python] wuchengyi2006 opened a new pull request #113: FIX plugin sw_pymysql error when connection haven't db

wuchengyi2006 opened a new pull request #113:
URL: https://github.com/apache/skywalking-python/pull/113


   <!-- Uncomment the following checklist WHEN AND ONLY WHEN you're adding a new plugin -->
   <!--
   - [ ] Add a test case for the new plugin
   - [ ] Add a component id in [the main repo](https://github.com/apache/skywalking/blob/master/oap-server/server-bootstrap/src/main/resources/component-libraries.yml#L415)
   - [ ] Add a logo in [the UI repo](https://github.com/apache/skywalking-rocketbot-ui/tree/master/src/views/components/topology/assets)
   - [ ] Rebuild the `requirements.txt` by running `tools/env/build_requirements_(linux|windows).sh`
   -->
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-python] kezhenxu94 commented on a change in pull request #113: FIX plugin sw_pymysql error when connection haven't db

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #113:
URL: https://github.com/apache/skywalking-python/pull/113#discussion_r549936057



##########
File path: skywalking/agent/__init__.py
##########
@@ -73,6 +73,15 @@ def __fini():
 
 
 def start():
+    flag = False
+    try:
+        from gevent import monkey
+        flag = monkey.is_module_patched("socket")
+    except Exception as e:
+        logger.warning("check gevent error:%s", e)
+    if flag:
+        import grpc.experimental.gevent as grpc_gevent
+        grpc_gevent.init_gevent()

Review comment:
       Here is the context: https://github.com/apache/skywalking/issues/5263#issuecomment-678732774




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-python] kezhenxu94 commented on a change in pull request #113: FIX plugin sw_pymysql error when connection haven't db

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #113:
URL: https://github.com/apache/skywalking-python/pull/113#discussion_r550240975



##########
File path: skywalking/agent/__init__.py
##########
@@ -73,6 +73,15 @@ def __fini():
 
 
 def start():
+    flag = False
+    try:
+        from gevent import monkey
+        flag = monkey.is_module_patched("socket")
+    except Exception as e:
+        logger.warning("check gevent error:%s", e)
+    if flag:
+        import grpc.experimental.gevent as grpc_gevent
+        grpc_gevent.init_gevent()

Review comment:
       OK I can get you point, sounds good to me, can you please slightly polish line 80-81 so that the warning logs are only printed when `monkey` really exists in users application, at the moment, it seems that when there is no `monkey` package installed, it prints the warning logs? I think that's confusing for users, right?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-python] kezhenxu94 merged pull request #113: FIX plugin sw_pymysql error when connection haven't db

Posted by GitBox <gi...@apache.org>.
kezhenxu94 merged pull request #113:
URL: https://github.com/apache/skywalking-python/pull/113


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-python] wuchengyi2006 commented on a change in pull request #113: FIX plugin sw_pymysql error when connection haven't db

Posted by GitBox <gi...@apache.org>.
wuchengyi2006 commented on a change in pull request #113:
URL: https://github.com/apache/skywalking-python/pull/113#discussion_r550230429



##########
File path: skywalking/agent/__init__.py
##########
@@ -73,6 +73,15 @@ def __fini():
 
 
 def start():
+    flag = False
+    try:
+        from gevent import monkey
+        flag = monkey.is_module_patched("socket")
+    except Exception as e:
+        logger.warning("check gevent error:%s", e)
+    if flag:
+        import grpc.experimental.gevent as grpc_gevent
+        grpc_gevent.init_gevent()

Review comment:
       A code two or more kinds of worker mode  




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-python] kezhenxu94 commented on a change in pull request #113: FIX plugin sw_pymysql error when connection haven't db

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #113:
URL: https://github.com/apache/skywalking-python/pull/113#discussion_r549935072



##########
File path: skywalking/agent/__init__.py
##########
@@ -73,6 +73,15 @@ def __fini():
 
 
 def start():
+    flag = False
+    try:
+        from gevent import monkey
+        flag = monkey.is_module_patched("socket")
+    except Exception as e:
+        logger.warning("check gevent error:%s", e)
+    if flag:
+        import grpc.experimental.gevent as grpc_gevent
+        grpc_gevent.init_gevent()

Review comment:
       Can you please explain why we add these lines in the agent? I remember these in the other thread but I suppose these should be in the targeted application, because the agent has nothing to do with `monkey` at all?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-python] kezhenxu94 commented on a change in pull request #113: FIX plugin sw_pymysql error when connection haven't db

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #113:
URL: https://github.com/apache/skywalking-python/pull/113#discussion_r550379006



##########
File path: skywalking/agent/__init__.py
##########
@@ -73,6 +73,15 @@ def __fini():
 
 
 def start():
+    flag = False
+    try:
+        from gevent import monkey
+        flag = monkey.is_module_patched("socket")
+    except ModuleNotFoundError:
+        logger.debug("it was found that no gevent was used,if you don't use,please ignore.")

Review comment:
       ```suggestion
           logger.debug("it was found that no gevent was used, if you don't use, please ignore.")
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-python] wuchengyi2006 commented on pull request #113: FIX plugin sw_pymysql error when connection haven't db

Posted by GitBox <gi...@apache.org>.
wuchengyi2006 commented on pull request #113:
URL: https://github.com/apache/skywalking-python/pull/113#issuecomment-752322834


   We found this error when connecting to the database but not specifying DB, such as executing the command ‘show databases’。


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-python] wuchengyi2006 commented on a change in pull request #113: FIX plugin sw_pymysql error when connection haven't db

Posted by GitBox <gi...@apache.org>.
wuchengyi2006 commented on a change in pull request #113:
URL: https://github.com/apache/skywalking-python/pull/113#discussion_r550378209



##########
File path: skywalking/agent/__init__.py
##########
@@ -73,6 +73,15 @@ def __fini():
 
 
 def start():
+    flag = False
+    try:
+        from gevent import monkey
+        flag = monkey.is_module_patched("socket")
+    except Exception as e:
+        logger.warning("check gevent error:%s", e)
+    if flag:
+        import grpc.experimental.gevent as grpc_gevent
+        grpc_gevent.init_gevent()

Review comment:
       you're right,I've tried to optimize it。




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-python] wuchengyi2006 commented on a change in pull request #113: FIX plugin sw_pymysql error when connection haven't db

Posted by GitBox <gi...@apache.org>.
wuchengyi2006 commented on a change in pull request #113:
URL: https://github.com/apache/skywalking-python/pull/113#discussion_r550228162



##########
File path: skywalking/agent/__init__.py
##########
@@ -73,6 +73,15 @@ def __fini():
 
 
 def start():
+    flag = False
+    try:
+        from gevent import monkey
+        flag = monkey.is_module_patched("socket")
+    except Exception as e:
+        logger.warning("check gevent error:%s", e)
+    if flag:
+        import grpc.experimental.gevent as grpc_gevent
+        grpc_gevent.init_gevent()

Review comment:
       Another scene,I use 'grpc_gevent.init_gevent()',but  don't have gevent(monkey.patch_all()),I use threadpool,it will had an error occurred:
   Traceback (most recent call last):
   
     File "src/gevent/event.py", line 159, in gevent._gevent_cevent.Event.wait
   
   gevent.exceptions.InvalidThreadUseError: (<Hub '' at 0x7f2f917627c0 epoll pending=0 ref=3 fileno=8 resolver=<gevent.resolver.thread.Resolver at 0x7f2f8eb07700 pool=<ThreadPool at 0x7f2f7de7a2e0 tasks=0 size=1 maxsize=10 hub=<Hub at 0x7f2f917627c0 thread_ident=0x7f2f8c914700>>> threadpool=<ThreadPool at 0x7f2f7de7a2e0 tasks=0 size=1 maxsize=10 hub=<Hub at 0x7f2f917627c0 thread_ident=0x7f2f8c914700>> thread_ident=0x7f2f8c914700>, None, <greenlet.greenlet object at 0x7f2f9045a5c0>)
   
   Traceback (most recent call last):
   
     File "src/gevent/event.py", line 159, in gevent._gevent_cevent.Event.wait
   
   Exception ignored in: 'grpc._cython.cygrpc.run_loop'
   
   Traceback (most recent call last):
   
     File "src/gevent/event.py", line 159, in gevent._gevent_cevent.Event.wait
   
     File "src/gevent/_abstract_linkable.py", line 425, in gevent._gevent_c_abstract_linkable.AbstractLinkable._wait
   
     File "src/gevent/_abstract_linkable.py", line 425, in gevent._gevent_c_abstract_linkable.AbstractLinkable._wait
   
     File "src/gevent/_abstract_linkable.py", line 425, in gevent._gevent_c_abstract_linkable.AbstractLinkable._wait
   
     File "src/gevent/_abstract_linkable.py", line 191, in gevent._gevent_c_abstract_linkable.AbstractLinkable._capture_hub
   
     File "src/gevent/_abstract_linkable.py", line 191, in gevent._gevent_c_abstract_linkable.AbstractLinkable._capture_hub
   
     File "src/gevent/_abstract_linkable.py", line 191, in gevent._gevent_c_abstract_linkable.AbstractLinkable._capture_hub
   
   gevent.exceptions.InvalidThreadUseError: (<Hub '' at 0x7f2f917627c0 epoll pending=0 ref=3 fileno=8 resolver=<gevent.resolver.thread.Resolver at 0x7f2f8eb07700 pool=<ThreadPool at 0x7f2f7de7a2e0 tasks=0 size=1 maxsize=10 hub=<Hub at 0x7f2f917627c0 thread_ident=0x7f2f8c914700>>> threadpool=<ThreadPool at 0x7f2f7de7a2e0 tasks=0 size=1 maxsize=10 hub=<Hub at 0x7f2f917627c0 thread_ident=0x7f2f8c914700>> thread_ident=0x7f2f8c914700>, None, <greenlet.greenlet object at 0x7f2f9045a5c0>)
   
   gevent.exceptions.InvalidThreadUseError: (<Hub '' at 0x7f2f917627c0 epoll pending=0 ref=3 fileno=8 resolver=<gevent.resolver.thread.Resolver at 0x7f2f8eb07700 pool=<ThreadPool at 0x7f2f7de7a2e0 tasks=0 size=1 maxsize=10 hub=<Hub at 0x7f2f917627c0 thread_ident=0x7f2f8c914700>>> threadpool=<ThreadPool at 0x7f2f7de7a2e0 tasks=0 size=1 maxsize=10 hub=<Hub at 0x7f2f917627c0 thread_ident=0x7f2f8c914700>> thread_ident=0x7f2f8c914700>, None, <greenlet.greenlet object at 0x7f2f9045a670>)
   
   Exception ignored in: 'grpc._cython.cygrpc.run_loop'
   
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org