xasyncio 0.2.1__tar.gz → 0.2.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.
Potentially problematic release.
This version of xasyncio might be problematic. Click here for more details.
- {xasyncio-0.2.1 → xasyncio-0.2.2}/PKG-INFO +1 -1
- {xasyncio-0.2.1 → xasyncio-0.2.2}/src/xasyncio/__init__.py +30 -28
- {xasyncio-0.2.1 → xasyncio-0.2.2}/.github/workflows/release.yml +0 -0
- {xasyncio-0.2.1 → xasyncio-0.2.2}/.gitignore +0 -0
- {xasyncio-0.2.1 → xasyncio-0.2.2}/LICENSE +0 -0
- {xasyncio-0.2.1 → xasyncio-0.2.2}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xasyncio
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: A package to simiplify multithreaded asyncio event loops
|
|
5
5
|
Project-URL: Homepage, https://github.com/shawn-peng/xasyncio
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/shawn-peng/xasyncio/issues
|
|
@@ -95,20 +95,21 @@ class AsyncThread(threading.Thread):
|
|
|
95
95
|
# if threading.current_thread() != self.thread:
|
|
96
96
|
# raise ThreadingError('Invalid thread: this function must be called in the loop thread')
|
|
97
97
|
|
|
98
|
-
def await_coroutine(self, coro):
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
98
|
+
def await_coroutine(self, coro, timeout=None):
|
|
99
|
+
return asyncio.run_coroutine_threadsafe(coro, self.loop).result(timeout)
|
|
100
|
+
|
|
101
|
+
# finish_event = threading.Event()
|
|
102
|
+
#
|
|
103
|
+
# async def _helper():
|
|
104
|
+
# try:
|
|
105
|
+
# await coro
|
|
106
|
+
# except Exception as e:
|
|
107
|
+
# traceback.print_exc()
|
|
108
|
+
#
|
|
109
|
+
# finish_event.set()
|
|
110
|
+
#
|
|
111
|
+
# self.loop.call_soon_threadsafe(self.loop.create_task, _helper())
|
|
112
|
+
# finish_event.wait()
|
|
112
113
|
|
|
113
114
|
|
|
114
115
|
class AsyncedThread:
|
|
@@ -176,20 +177,21 @@ class AsyncedThread:
|
|
|
176
177
|
# if threading.current_thread() != self.thread:
|
|
177
178
|
# raise ThreadingError('Invalid thread: this function must be called in the loop thread')
|
|
178
179
|
|
|
179
|
-
def await_coroutine(self, coro):
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
180
|
+
def await_coroutine(self, coro, timeout=None):
|
|
181
|
+
return asyncio.run_coroutine_threadsafe(coro, self.loop).result(timeout)
|
|
182
|
+
|
|
183
|
+
# finish_event = threading.Event()
|
|
184
|
+
#
|
|
185
|
+
# async def _helper():
|
|
186
|
+
# try:
|
|
187
|
+
# await coro
|
|
188
|
+
# except Exception as e:
|
|
189
|
+
# traceback.print_exc()
|
|
190
|
+
#
|
|
191
|
+
# finish_event.set()
|
|
192
|
+
#
|
|
193
|
+
# self.loop.call_soon_threadsafe(self.loop.create_task, _helper())
|
|
194
|
+
# finish_event.wait()
|
|
193
195
|
|
|
194
196
|
|
|
195
197
|
def blocking_call_w_loop(loop, func, *args):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|