wslink 2.2.0__tar.gz → 2.2.1__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.
- {wslink-2.2.0 → wslink-2.2.1}/PKG-INFO +1 -1
- {wslink-2.2.0 → wslink-2.2.1}/setup.cfg +1 -1
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/websocket.py +15 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink.egg-info/PKG-INFO +1 -1
- {wslink-2.2.0 → wslink-2.2.1}/MANIFEST.in +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/README.rst +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/setup.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/LICENSE +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/__init__.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/backends/__init__.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/backends/aiohttp/__init__.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/backends/aiohttp/launcher.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/backends/aiohttp/relay.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/backends/generic/__init__.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/backends/generic/core.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/backends/jupyter/__init__.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/backends/jupyter/core.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/backends/tornado/__init__.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/backends/tornado/core.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/chunking.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/launcher.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/protocol.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/publish.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/relay.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/server.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/ssl_context.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink/uri.py +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink.egg-info/SOURCES.txt +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink.egg-info/dependency_links.txt +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink.egg-info/requires.txt +0 -0
- {wslink-2.2.0 → wslink-2.2.1}/src/wslink.egg-info/top_level.txt +0 -0
@@ -67,17 +67,28 @@ class LinkProtocol(object):
|
|
67
67
|
|
68
68
|
|
69
69
|
class NetworkMonitor:
|
70
|
+
"""
|
71
|
+
Provide context manager for increase/decrease pending request
|
72
|
+
either synchronously or asynchronously.
|
73
|
+
|
74
|
+
The Asynchronous version also await completion.
|
75
|
+
"""
|
76
|
+
|
70
77
|
def __init__(self):
|
78
|
+
|
71
79
|
self.pending = 0
|
72
80
|
self.event = asyncio.Event()
|
73
81
|
|
74
82
|
def network_call_completed(self):
|
83
|
+
"""Trigger completion event"""
|
75
84
|
self.event.set()
|
76
85
|
|
77
86
|
def on_enter(self, *args, **kwargs):
|
87
|
+
"""Increase pending request"""
|
78
88
|
self.pending += 1
|
79
89
|
|
80
90
|
def on_exit(self, *args, **kwargs):
|
91
|
+
"""Decrease pending request and trigger completion event if we reach 0 pending request"""
|
81
92
|
self.pending -= 1
|
82
93
|
if self.pending == 0 and not self.event.is_set():
|
83
94
|
self.event.set()
|
@@ -97,6 +108,10 @@ class NetworkMonitor:
|
|
97
108
|
|
98
109
|
async def __aexit__(self, exc_t, exc_v, exc_tb):
|
99
110
|
self.on_exit()
|
111
|
+
await self.completion()
|
112
|
+
|
113
|
+
async def completion(self):
|
114
|
+
"""Await completion of any pending network request"""
|
100
115
|
while self.pending:
|
101
116
|
self.event.clear()
|
102
117
|
await self.event.wait()
|
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
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|