xasyncio 0.1.7__py3-none-any.whl → 0.2.0__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
@@ -2,20 +2,22 @@ import asyncio
2
2
  import threading
3
3
  import traceback
4
4
 
5
+ from typing import *
6
+
5
7
 
6
8
  class ThreadingError(Exception):
7
9
  pass
8
10
 
9
11
 
10
- class ThreadedEventLoop:
12
+ class AsyncThread(threading.Thread):
11
13
  def __init__(self, name):
14
+ super().__init__()
12
15
  self.name = name
13
- self.thread = threading.Thread(target=self.run)
14
16
  self.events = {}
15
17
  self.events_out_thread = {}
16
- self.loop: asyncio.BaseEventLoop = None
18
+ self.loop: asyncio.BaseEventLoop | None = None
17
19
  self.stopped = True
18
- self.thread.start()
20
+ self.start()
19
21
  self.create_out_thread_event('loop_started')
20
22
  self.wait_out_thread_event('loop_started')
21
23
 
@@ -35,7 +37,8 @@ class ThreadedEventLoop:
35
37
  # print('calling from another loop')
36
38
  print(f'Threaded loop {self.name} stopping')
37
39
  self.call_sync(self._stop)
38
- self.thread.join(10)
40
+ # self.thread.join(10)
41
+ self.join(10)
39
42
 
40
43
  def _mark_running(self, running=True):
41
44
  # if running:
@@ -46,11 +49,14 @@ class ThreadedEventLoop:
46
49
 
47
50
  def run(self):
48
51
  self.loop = asyncio.new_event_loop()
49
- # self.loop = asyncio.get_event_loop()
50
52
  # Need to call this in the loop, mainly because need to make sure the loop is running
53
+ # debugging version
51
54
  # self.loop.call_soon_threadsafe(
52
55
  # lambda: (
53
- # print('notifying loop started'), self._mark_running(), print(self.stopped), self.notify_out_thread_event('loop_started')))
56
+ # print('notifying loop started'),
57
+ # self._mark_running(),
58
+ # print(self.stopped),
59
+ # self.notify_out_thread_event('loop_started')))
54
60
  self.loop.call_soon_threadsafe(
55
61
  lambda: (
56
62
  self._mark_running(), self.notify_out_thread_event('loop_started')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xasyncio
3
- Version: 0.1.7
3
+ Version: 0.2.0
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=IzdT5rpma3Rs0rh-Seqtg-JrNWTJaVEB9ULwU3-DX74,4060
2
+ xasyncio-0.2.0.dist-info/METADATA,sha256=WhgRH2CYfUAWmaHnlsRyNBbDzyiY1rkn_FO9hXVEC0U,488
3
+ xasyncio-0.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
4
+ xasyncio-0.2.0.dist-info/licenses/LICENSE,sha256=fHWKRzBMuHQa8EYpadXv8pSmA8XnR8FlirkvLoayV1I,1066
5
+ xasyncio-0.2.0.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- xasyncio/__init__.py,sha256=bk-3Vwq6yH3NNCkFgGKMqUCN3TnAJsGaFGgtaVWI2Z0,3996
2
- xasyncio-0.1.7.dist-info/METADATA,sha256=7DSRHvyONkOwWo2kLiSrCnyiY0S7f1tRAevxnC4oTos,488
3
- xasyncio-0.1.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
4
- xasyncio-0.1.7.dist-info/licenses/LICENSE,sha256=fHWKRzBMuHQa8EYpadXv8pSmA8XnR8FlirkvLoayV1I,1066
5
- xasyncio-0.1.7.dist-info/RECORD,,