@@ -52,7 +52,6 @@ def test_CRUD(client):
5252 print ("is OK: " , OK )
5353 print ("HTTP status code: " , http_status_code ,"\n " )
5454
55- time .sleep (5 )
5655 # test delete pod
5756 print ("--test delete pod:" )
5857 response_dict ,OK ,http_status_code = client .deleteResource (kind = "Pod" , namespace = "default" , name = "busybox" )
@@ -69,7 +68,7 @@ def test_watcher(client,namespce,kind,name=None):
6968def deal_watch (* args ):
7069 def tt (jsonObj = None ,args = args ):
7170 print (dictToJsonString (jsonObj )[:20 ])
72-
71+
7372 return tt
7473
7574def test_watcher_base (client ,namespce ,kind ,name = None ,handlerFunction = None ,** kwargs ):
@@ -83,9 +82,13 @@ def main():
8382 token = ""
8483
8584 client = KubernetesClient (url = url ,token = token )
86- test_watcher_base (client ,"default" ,"Pod" ,handlerFunction = deal_watch (),limit = 1 , timeoutSeconds = 2 )
85+ test_watcher_base (client ,"default" ,"Pod" ,handlerFunction = deal_watch (),timeoutSeconds = 3 )
8786 test_CRUD (client = client )
87+
88+ print ("current thread count: " ,KubernetesClient .getWatchThreadCount ())
8889 time .sleep (7 )
90+ # because of the timeoutSecond=3, watching thread is leave.
91+ print ("current thread count: " ,KubernetesClient .getWatchThreadCount ())
8992
9093if __name__ == '__main__' :
9194 main ()
0 commit comments