kwebsocket 1.0__tar.gz → 1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {kwebsocket-1.0 → kwebsocket-1.2}/PKG-INFO +2 -2
- {kwebsocket-1.0 → kwebsocket-1.2}/kwebsocket/__init__.py +1 -1
- {kwebsocket-1.0 → kwebsocket-1.2}/kwebsocket/rfdszbfnbxrdfgvxrhbdtxrhtbs.py +44 -36
- {kwebsocket-1.0 → kwebsocket-1.2}/kwebsocket.egg-info/PKG-INFO +2 -2
- {kwebsocket-1.0 → kwebsocket-1.2}/kwebsocket.egg-info/SOURCES.txt +0 -0
- {kwebsocket-1.0 → kwebsocket-1.2}/kwebsocket.egg-info/dependency_links.txt +0 -0
- {kwebsocket-1.0 → kwebsocket-1.2}/kwebsocket.egg-info/requires.txt +0 -0
- {kwebsocket-1.0 → kwebsocket-1.2}/kwebsocket.egg-info/top_level.txt +0 -0
- {kwebsocket-1.0 → kwebsocket-1.2}/setup.cfg +0 -0
- {kwebsocket-1.0 → kwebsocket-1.2}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 1.2
|
|
2
2
|
Name: kwebsocket
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2
|
|
4
4
|
Summary: kwebsocket
|
|
5
5
|
Home-page: UNKNOWN
|
|
6
6
|
Author: 百里
|
|
@@ -9,5 +9,5 @@ Maintainer: 坤坤
|
|
|
9
9
|
Maintainer-email: fk1402936534@qq.com
|
|
10
10
|
License: MIT License
|
|
11
11
|
Description: UNKNOWN
|
|
12
|
-
Keywords: kwebsocket1.
|
|
12
|
+
Keywords: kwebsocket1.2
|
|
13
13
|
Platform: UNKNOWN
|
|
@@ -15,27 +15,28 @@ class vsregrsgtrdhbrhtrsgrshydtrsegregsresgr:
|
|
|
15
15
|
'status':False
|
|
16
16
|
}
|
|
17
17
|
def __connect(self):
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
if not self.wsobj:
|
|
19
|
+
import websocket
|
|
20
|
+
for i in range(100):
|
|
21
|
+
self.wsobj = websocket.WebSocket()
|
|
22
|
+
try:
|
|
23
|
+
self.wsobj.connect(self.__config['url'])
|
|
24
|
+
except websocket._exceptions.WebSocketBadStatusException:
|
|
25
|
+
try:self.wsobj.close()
|
|
26
|
+
except:pass
|
|
27
|
+
self.wsobj=None
|
|
28
|
+
if i>=self.__config['break']:
|
|
29
|
+
self.__close_th_lock()
|
|
30
|
+
raise Exception('连接已中止,请重新连接')
|
|
31
|
+
time.sleep(0.1)
|
|
32
|
+
except:
|
|
33
|
+
try:self.wsobj.close()
|
|
34
|
+
except:pass
|
|
35
|
+
self.wsobj=None
|
|
28
36
|
self.__close_th_lock()
|
|
29
|
-
raise
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
try:self.wsobj.close()
|
|
33
|
-
except:pass
|
|
34
|
-
self.wsobj=None
|
|
35
|
-
self.__close_th_lock()
|
|
36
|
-
raise
|
|
37
|
-
else:
|
|
38
|
-
break
|
|
37
|
+
raise
|
|
38
|
+
else:
|
|
39
|
+
break
|
|
39
40
|
def __start_th_lock(self):
|
|
40
41
|
"""开启线程锁 多线程中建议开启 注意 这个python多线程锁 而不是数据库事务锁"""
|
|
41
42
|
if not self.__thlock['obj']:
|
|
@@ -51,6 +52,11 @@ class vsregrsgtrdhbrhtrsgrshydtrsegregsresgr:
|
|
|
51
52
|
self.__thlock['status']=False
|
|
52
53
|
if self.__config['debug']:
|
|
53
54
|
kwebsocket_print_log('退出线程锁cache')
|
|
55
|
+
def close(self):
|
|
56
|
+
if self.wsobj:
|
|
57
|
+
try:self.wsobj.close()
|
|
58
|
+
except:pass
|
|
59
|
+
self.wsobj=None
|
|
54
60
|
def connect(self,url,th_lock=False):
|
|
55
61
|
"""设置连接
|
|
56
62
|
|
|
@@ -68,22 +74,23 @@ class vsregrsgtrdhbrhtrsgrshydtrsegregsresgr:
|
|
|
68
74
|
|
|
69
75
|
def send(self,text):
|
|
70
76
|
for i in range(100):
|
|
71
|
-
|
|
72
|
-
self.__connect()
|
|
77
|
+
self.__connect()
|
|
73
78
|
try:
|
|
74
79
|
self.wsobj.send(text)
|
|
75
80
|
except ConnectionAbortedError:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
self.close()
|
|
82
|
+
if i>=self.__config['break']:
|
|
83
|
+
self.__close_th_lock()
|
|
84
|
+
raise Exception('连接已中止,请重新连接')
|
|
85
|
+
time.sleep(0.1)
|
|
86
|
+
except BrokenPipeError:
|
|
87
|
+
self.close()
|
|
79
88
|
if i>=self.__config['break']:
|
|
80
89
|
self.__close_th_lock()
|
|
81
90
|
raise Exception('连接已中止,请重新连接')
|
|
82
91
|
time.sleep(0.1)
|
|
83
92
|
except:
|
|
84
|
-
|
|
85
|
-
except:pass
|
|
86
|
-
self.wsobj=None
|
|
93
|
+
self.close()
|
|
87
94
|
self.__close_th_lock()
|
|
88
95
|
raise
|
|
89
96
|
else:
|
|
@@ -92,22 +99,23 @@ class vsregrsgtrdhbrhtrsgrshydtrsegregsresgr:
|
|
|
92
99
|
def recv(self):
|
|
93
100
|
"""接收数据"""
|
|
94
101
|
for i in range(100):
|
|
95
|
-
|
|
96
|
-
self.__connect()
|
|
102
|
+
self.__connect()
|
|
97
103
|
try:
|
|
98
104
|
data = self.wsobj.recv()
|
|
99
105
|
except ConnectionAbortedError:
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
self.close()
|
|
107
|
+
if i>=self.__config['break']:
|
|
108
|
+
self.__close_th_lock()
|
|
109
|
+
raise Exception('连接已中止,请重新连接')
|
|
110
|
+
time.sleep(0.1)
|
|
111
|
+
except BrokenPipeError:
|
|
112
|
+
self.close()
|
|
103
113
|
if i>=self.__config['break']:
|
|
104
114
|
self.__close_th_lock()
|
|
105
115
|
raise Exception('连接已中止,请重新连接')
|
|
106
116
|
time.sleep(0.1)
|
|
107
117
|
except:
|
|
108
|
-
|
|
109
|
-
except:pass
|
|
110
|
-
self.wsobj=None
|
|
118
|
+
self.close()
|
|
111
119
|
self.__close_th_lock()
|
|
112
120
|
raise
|
|
113
121
|
else:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 1.2
|
|
2
2
|
Name: kwebsocket
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2
|
|
4
4
|
Summary: kwebsocket
|
|
5
5
|
Home-page: UNKNOWN
|
|
6
6
|
Author: 百里
|
|
@@ -9,5 +9,5 @@ Maintainer: 坤坤
|
|
|
9
9
|
Maintainer-email: fk1402936534@qq.com
|
|
10
10
|
License: MIT License
|
|
11
11
|
Description: UNKNOWN
|
|
12
|
-
Keywords: kwebsocket1.
|
|
12
|
+
Keywords: kwebsocket1.2
|
|
13
13
|
Platform: UNKNOWN
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|