wisp-python 0.4.1__tar.gz → 0.4.3__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.
- {wisp_python-0.4.1 → wisp_python-0.4.3}/PKG-INFO +1 -1
- {wisp_python-0.4.1 → wisp_python-0.4.3}/pyproject.toml +1 -1
- {wisp_python-0.4.1 → wisp_python-0.4.3}/src/wisp/__init__.py +1 -1
- {wisp_python-0.4.1 → wisp_python-0.4.3}/src/wisp/server/__main__.py +11 -2
- {wisp_python-0.4.1 → wisp_python-0.4.3}/src/wisp/server/connection.py +8 -1
- {wisp_python-0.4.1 → wisp_python-0.4.3}/src/wisp/server/http.py +1 -1
- {wisp_python-0.4.1 → wisp_python-0.4.3}/src/wisp_python.egg-info/PKG-INFO +1 -1
- {wisp_python-0.4.1 → wisp_python-0.4.3}/LICENSE +0 -0
- {wisp_python-0.4.1 → wisp_python-0.4.3}/README.md +0 -0
- {wisp_python-0.4.1 → wisp_python-0.4.3}/setup.cfg +0 -0
- {wisp_python-0.4.1 → wisp_python-0.4.3}/src/wisp/server/__init__.py +0 -0
- {wisp_python-0.4.1 → wisp_python-0.4.3}/src/wisp/server/net.py +0 -0
- {wisp_python-0.4.1 → wisp_python-0.4.3}/src/wisp/server/ratelimit.py +0 -0
- {wisp_python-0.4.1 → wisp_python-0.4.3}/src/wisp_python.egg-info/SOURCES.txt +0 -0
- {wisp_python-0.4.1 → wisp_python-0.4.3}/src/wisp_python.egg-info/dependency_links.txt +0 -0
- {wisp_python-0.4.1 → wisp_python-0.4.3}/src/wisp_python.egg-info/requires.txt +0 -0
- {wisp_python-0.4.1 → wisp_python-0.4.3}/src/wisp_python.egg-info/top_level.txt +0 -0
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import argparse
|
|
2
|
-
import
|
|
2
|
+
import asyncio
|
|
3
|
+
try:
|
|
4
|
+
import uvloop
|
|
5
|
+
use_uvloop = True
|
|
6
|
+
except ImportError:
|
|
7
|
+
use_uvloop = False
|
|
3
8
|
|
|
4
9
|
import wisp
|
|
5
10
|
import wisp.server.http
|
|
@@ -21,4 +26,8 @@ if __name__ == "__main__":
|
|
|
21
26
|
parser.add_argument("--allow-private", action="store_true", help="Allow connections to private IP addresses.")
|
|
22
27
|
args = parser.parse_args()
|
|
23
28
|
|
|
24
|
-
|
|
29
|
+
if use_uvloop:
|
|
30
|
+
uvloop.run(wisp.server.http.main(args))
|
|
31
|
+
else:
|
|
32
|
+
print("Warning: Importing uvloop failed. Falling back to asyncio, which is slower.")
|
|
33
|
+
asyncio.run(wisp.server.http.main(args))
|
|
@@ -163,7 +163,8 @@ class WispConnection:
|
|
|
163
163
|
if not stream_id in self.active_streams:
|
|
164
164
|
return #stream already closed
|
|
165
165
|
stream = self.active_streams[stream_id]
|
|
166
|
-
stream["conn"]
|
|
166
|
+
if stream["conn"]:
|
|
167
|
+
stream["conn"].close()
|
|
167
168
|
|
|
168
169
|
#kill the running tasks associated with this stream
|
|
169
170
|
if not stream["connect_task"].done():
|
|
@@ -181,6 +182,12 @@ class WispConnection:
|
|
|
181
182
|
data = await self.ws.recv()
|
|
182
183
|
except ConnectionClosed:
|
|
183
184
|
break
|
|
185
|
+
except Exception as e:
|
|
186
|
+
print(f"Receiving data from websocket failed: {e}")
|
|
187
|
+
break
|
|
188
|
+
|
|
189
|
+
if not isinstance(data, bytes):
|
|
190
|
+
continue #ignore non binary frames
|
|
184
191
|
|
|
185
192
|
#implement bandwidth limits
|
|
186
193
|
await ratelimit.limit_client_bandwidth(self.client_ip, len(data), "ws")
|
|
@@ -79,5 +79,5 @@ async def main(args):
|
|
|
79
79
|
|
|
80
80
|
limit_task = asyncio.create_task(ratelimit.reset_limits_timer())
|
|
81
81
|
print(f"listening on {args.host}:{args.port}")
|
|
82
|
-
async with serve(connection_handler, args.host, int(args.port), process_request=request_handler):
|
|
82
|
+
async with serve(connection_handler, args.host, int(args.port), process_request=request_handler, compression=None):
|
|
83
83
|
await asyncio.Future()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|