xasyncio 0.2.1__py3-none-any.whl → 0.2.2__py3-none-any.whl

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/__init__.py CHANGED
@@ -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
- # task = self.loop.create_task(coro)
100
- finish_event = threading.Event()
101
-
102
- async def _helper():
103
- try:
104
- await coro
105
- except Exception as e:
106
- traceback.print_exc()
107
-
108
- finish_event.set()
109
-
110
- self.loop.call_soon_threadsafe(self.loop.create_task, _helper())
111
- finish_event.wait()
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
- # task = self.loop.create_task(coro)
181
- finish_event = threading.Event()
182
-
183
- async def _helper():
184
- try:
185
- await coro
186
- except Exception as e:
187
- traceback.print_exc()
188
-
189
- finish_event.set()
190
-
191
- self.loop.call_soon_threadsafe(self.loop.create_task, _helper())
192
- finish_event.wait()
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):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xasyncio
3
- Version: 0.2.1
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
@@ -0,0 +1,5 @@
1
+ xasyncio/__init__.py,sha256=8_wK431-8KTNTQXMiSahopLFqfgoD-tRByiTh_W3tDQ,6672
2
+ xasyncio-0.2.2.dist-info/METADATA,sha256=0QCfV_eS4CKgwQ0Uc8sk4XUctmSR8FXpBilBx_l8sAU,488
3
+ xasyncio-0.2.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
4
+ xasyncio-0.2.2.dist-info/licenses/LICENSE,sha256=fHWKRzBMuHQa8EYpadXv8pSmA8XnR8FlirkvLoayV1I,1066
5
+ xasyncio-0.2.2.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- xasyncio/__init__.py,sha256=rs9oGlXapDlLBTVojyGzJPnJlMGYwiJRf59ryNK2tpE,6480
2
- xasyncio-0.2.1.dist-info/METADATA,sha256=nEu4aqMmsegNBBDqoo7P4VWnnYXexLRA4fcieOPnoQY,488
3
- xasyncio-0.2.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
4
- xasyncio-0.2.1.dist-info/licenses/LICENSE,sha256=fHWKRzBMuHQa8EYpadXv8pSmA8XnR8FlirkvLoayV1I,1066
5
- xasyncio-0.2.1.dist-info/RECORD,,